View Full Version : how can the store send one POST to update multiple records?

7 Sep 2010, 4:01 PM
I have the need to update many records at once.
I have a function that fires when the user clicks on "publish selected records". The problem is, there is one POST for every record updated. Even if I update all the records and call store.commitChanges() only once, there are multiple POST requests.

The application on the back end needs to see all the updated records in one call.
I tried to set listful: true on the writer, but apperently this doesn't work when my backend expects an array...

My writer:

var writer = new Ext.data.JsonWriter({
encode: false,
writeAllFields: false,
listful: true
My button handler:

function publishSelected(btn, ev) {
var selected = userGrid.getSelectionModel().getSelections();

var row = selected[i];

if (row.get('published') == 'yes'){
row.set('published', 'no');
} else {
row.set('published', 'yes');

store.proxy = publishProxy; // <-- change proxy for this one app!
store.proxy = resultsProxy;
What am I doing wrong??

Many thanks!

8 Sep 2010, 12:13 AM
1. I assume you configured the store with autoSave:false?
2. You can't change the proxy of a store by simply assigning it to the proxy property! You are forgetting that store registers events on the proxy.
3. Save is asynchronous. You have to wait until all records are written before commit the changes (doesn't a save already do this?).