I have a Ext JS grid store with autosave
set to false
.
I want to clear ONLY the local store, without affecting/deleting records in the server.
If I try store.removeAll()
, then when the next store write occurs, all records are deleted.
How to call store.removeAll
with clearing all pending changes after it?
Store.loadData([],false);
This statement drop local cache and not send changes to server side
The removeAll has a silent parameter that can be used to clear records rather than delete from the server:
http://docs.sencha.com/extjs/3.4.0/#!/api/Ext.data.Store-method-removeAll
gridPanel.store.removeAll(true);
From the code comments:
if (silent !== true) { // <-- prevents write-actions when we just want to clear a store.
this.fireEvent('clear', this, items);
}
If you then manually want to update a GridPanel to clear all rows you need to call:
gridPanel.view.refresh();
For ExtJS 4.1, this will clear buffer cache (prefetched data), so the next time you load (or loadPage), store will reload the pages from scratch:
store.pageMap.clear();
which was previously done as:
store.prefetchData.clear();
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With