PDA

View Full Version : how to change the structure of post data [with store's restful option]



kentkwun
22 Oct 2010, 9:49 PM
now use spring 3 mvc and extjs restful to save the record.
but the data post by extjs is like this: {"undefine":{"id":"01234567"}}.
i just want the data like this: {"id":"01234567"} and spring will auto inject into javabean by reflection.
so can i change the post data structure by extjs config or not?
thank you !

Condor
22 Oct 2010, 10:23 PM
You can post anything you want by specifying a render method in your JsonWriter config.

kentkwun
22 Oct 2010, 10:25 PM
thank you so much , can you give me an example?

Condor
22 Oct 2010, 10:48 PM
Something like:

writer: new Ext.data.JsonWriter({
...
render: function(params, baseParams, data) {
var jdata = Ext.apply({}, data, baseParams);
params.jsonData = jdata;
}
})
Disclaimer: Completely untested code!