PDA

View Full Version : refresh grid/store after data changed in store



karel_karel
4 Sep 2012, 3:56 AM
Hi,
I have a store with loaded data and filter on this store. Then I change one item in the store (not in database) and want to refresh the store(/grid) without reloading the data from DB so that the filter filters considering the changes i made. Is there any method for this? I can not find any.

Thanks
Tomas

Farish
4 Sep 2012, 4:15 AM
its not clear to me what you want to do. do you want to cancel the changes so that the old data is visible again or you are not able to see the change which you made in the grid and want to refresh the view?

karel_karel
4 Sep 2012, 5:39 AM
i have data in store, which are visible in grid. the store has filter (for example with condition item.Flag != 'A'), i change Flag on one item in store to 'A' and it is still visible. Is it clear now?
P.S.: Sorry if my english is bad.

scottmartin
4 Sep 2012, 5:40 AM
Changes made to the store are automatically seen by the grid.

ex:
record.set(field,value);

Scott.

Farish
4 Sep 2012, 5:47 AM
ok. i think I understand your problem now. I am not sure if it will work but give it a try. After you change a record, do the following:


grid.getView().refresh();

Farish
4 Sep 2012, 6:02 AM
I tried the above and it doesnt work. what you can do is to create a listener for the event which is fired when you change data in your store and then reapply the existing filters. I am giving you an example when you change something using the rowediting plugin in a grid:


rowEditing.on('edit', function(editor, e, eOpts) {
var store = editor.grid.getStore();
var filters = editor.grid.getStore().filters;
for(var i=0; i<filters.length; i++)
store.filter(filters[i]);
});

this may not be the best way to do it but it works. may be someone else can suggest something better.

karel_karel
4 Sep 2012, 6:22 AM
Thanks, that helped.