PDA

View Full Version : Problem refreshing grid view when store data changes



smares
27 Apr 2011, 2:44 AM
Hey guys, I am having a weird problem with my grid which is bound to a grouping store utilizing a JSON reader. The store is using remove and update listeners that simply refresh the view of the grid. When I remove an item from the grid using


var selection = grid.getSelectionModel().getSelections();
Ext.each(selection, grid.getStore().remove, grid.getStore());two items disappear from the grid at once. However, if I remove the remove listener and change my remove code to


var selection = grid.getSelectionModel().getSelections();
Ext.each(selection, grid.getStore().remove, grid.getStore());
grid.getView().refresh();everything works as expected. Any idea what is wrong?

Tim Toady
27 Apr 2011, 5:46 AM
You shouldn't need to refresh the view when removing an item. Is there something you are trying to accomplish not mentioned? On a side note, store.remove() can take an array of records so you don't need loop through them yourself.

smares
27 Apr 2011, 6:10 AM
If I don't refresh the view, the group information is incorrect (my groups contain the total number of items per group).

Tim Toady
27 Apr 2011, 6:37 AM
Oh I hadn't considered that. If you want to refresh based on an event, then you can certainly use the rowremoved event on the groupingview.