PDA

View Full Version : Problem with Restful grid & removing rows...



useless
17 Jan 2011, 1:59 PM
I can post more code snippets if required, but here is the gist of it...

I have a restful grid setup, I have a checkbox selection model for the first column, and a remove button in the toolbar.

My "remove" BASICALLY looks like this:


handler: function() {
var sm = grid.getSelectionModel(),
sel = selectionModel.getSelections();

if (sm.hasSelection()){
msgStore.remove( sel );
msgStore.reload();
}
}

If I have 1 item check'd and click delete, it deletes just fine.

If I have more than 1 item check'd, let's say 3 items in this example, it sends the delete request:
3 times for the first item,
2 times for the second item,
1 time for the last item...

etc..

Any idea what might be going on here? I even tried looping thru each selected item and removing them one by one using "sel[i]" but it did the same thing..

Condor
18 Jan 2011, 12:52 AM
msgStore.autoSave = false;
msgStore.remove(sel);
msgStore.save();
msgStore.autoSave = true;

useless
18 Jan 2011, 5:06 AM
So this is a known bug, or am I doing something wrong?

Condor
18 Jan 2011, 6:41 AM
Not really a bug.

Store.remove(Array) is removing every record separately, so it will fire several remove requests without waiting for the previous one to finish.

autoSave:true should only be used for one single action at a time.

varunach
17 Apr 2011, 8:58 PM
In my case when i do


grid.getStore().autoSave = false;
grid.getstore().remove(record);
grid.getStore().save();

the record is removed from the grid, the grid sends the delete request to the server, server responds with OK status, but record reappears after a second or so... but when I refresh the page, the removed record does not get reloaded into the the store. Why does the record reappear?