PDA

View Full Version : GridPanel.store.remove sending duplicate requests !



nbw
26 Mar 2011, 9:04 PM
I am seeing a problem with my GridPanel sending duplicate requests when the panel is configured with a multiselect RowSelectionModel.

My GridPanel looks like this:



var myGridPanel = new Ext.grid.GridPanel({
border: false,
store: myStore,
sm: new Ext.grid.RowSelectionModel({singleSelect: false}),
columns: columns,
tbar: [{
text:'Refresh',
handler: onRefresh
},'-',{
text: 'Delete',
handler: onDelete
}]
});


My delete handler looks like this:



function onDelete() {
var records = myGridPanel.getSelectionModel().getSelections();
if (records) {
myGridPanel.store.remove(records);
}
}


When I select 2 rows in my grid panel and click the delete button I am seeing that records is in fact an array of 2 items, the ones I select and these are what are passed to the store's remove method. However, when I look at the network tab of the JS debugger after the remove method is called I am seeing 3 requests go to the sever with one of them being a duplicate. My store is restful. The requests going out would be something like this:

DELETE
/MyAPP/foo/33

DELETE
/MyApp/foo/33

DELETE
/MyApp/foo/34

This looks like an extjs bug, I'm using 3.3.1. I haven't quite figured out why yet but even though Ext.data.Store.Ext.extend.remove records param is an Array of size 2, Ext.apply.each is iterating over the first records twice and fires two remove events for it.

Thoughts?

-NBW

nbw
26 Mar 2011, 10:56 PM
It looks like this is a problem even if I do not pass an array into store.remove(). If I have singleSelect set to false on my GridPanel, call getSelections() on the GridPanel's selection model in my button handler, and then iterate over the records I get back passing each one into store.remove() one at a time I still see the CRUD action (DELETE in this case) being performed multiple times on the 1st record. It will send a request for the 1st record X number of times where X is the number of records returned by the GridPanel.getSelectionModel().getSelections().