PDA

View Full Version : Dynamically adding row to a grid not working.



chiconerd
21 Oct 2010, 9:04 PM
Hi I have a code where I call Json data into a grid and the grid is filling up and has pagination and all that stuff...

now what I wanted to do was after all that is done add another record manually.. so lets say after the json data is loaded into the grid I add something else manually but for some reason this is not working.

I used the following code for the manually adding


var u = new userGrid.store.recordType({
name: '',
lname: '',
username : ''
});

store.add(u);


the only thing that i see that happens here is the blank row is created but after the json data is loaded the blank row is not there any more.

is there a way to do this?

chiconerd
21 Oct 2010, 9:33 PM
I guess I should have searched better before asking.
I found the answer.


store.load({add:true})
makes any data append to the current store. in case anyone has this question in the future.

Condor
22 Oct 2010, 3:09 AM
Alternatively you could insert the empty row after the store has finished loading.

chiconerd
22 Oct 2010, 7:59 AM
I see.. but I ran into a problem and I want to know if there is something that could be done about it.

I am using restful and whenever I add the new row it makes a call to the server to create the new record, but the record is empty. is there a way I could tell rest not to send the create method until a save btn is clicked?

I was trying batch but that doesn't work with rest.

Condor
22 Oct 2010, 9:21 AM
You could configure the store with autoSave:false and call save() yourself.

Alternatively you could configure some fields with allowBlank:false so the store won't save the record until it is valid.

chiconerd
22 Oct 2010, 9:55 PM
Thanks for the answer Condor, found it on the API sorry for not posting about it.