PDA

View Full Version : How to save new data or changed data back to server side!



Smash_hit
16 Oct 2007, 9:52 PM
I wanna know how to save changed data or newly created data back to the file(server side or an local xml file) which I loaded through httpProxy. I used editorGrid as my basic grid. I looked through Ext documentation and found commitChange function in Store class, but I didn't know how to use it and make it work. Could anyone show a demostration on it? thks!!

By the way, I wanna use this grid to select several records and delete them, how can I do that, getAt and getById functions are insufficient to fulfill my purpose.

lupin85.luca
23 Oct 2007, 1:10 AM
I wanna know how to save changed data or newly created data back to the file(server side or an local xml file) which I loaded through httpProxy. I used editorGrid as my basic grid. I looked through Ext documentation and found commitChange function in Store class, but I didn't know how to use it and make it work. Could anyone show a demostration on it? thks!!

By the way, I wanna use this grid to select several records and delete them, how can I do that, getAt and getById functions are insufficient to fulfill my purpose.

I'm also interested in saving changed data.
Do you find any solution?
Thanks

Smash_hit
30 Oct 2007, 12:22 AM
Maybe you can put your selected data into an form, then do whatever operation you want.

Animal
30 Oct 2007, 12:32 AM
It's really up to your programming and design abilities, but creating XML from a Store has been discussed many times.

Here is a function that will create an XML element from a Record:



Ext.override(Ext.data.Record, {
asXml : function(rowIndex) {
var r = this.store.reader.meta;
var elName = r.record;
var result = "<" + elName + " id=\"" + this.id + "\">";
this.fields.each(function(f) {
result += "<" + f.name;
if (f.type && f.type !== "auto") {
result += " type=\"" + f.type + "\"";
}
result += ">" + this.get(f.name) + "</" + f.name + ">";
}, this);
return result + "</" + elName + ">";
}
});


If you add a listener for the Store's update event, the handler be invoked for each modified Record when you call commit. and will be passed each modified record.

Convert them to XML, concatenate them up into a document string, add the correct XML tags to wrap it, and post it usnig Ext.Ajax. Read the docs on that, it's easy.