Reputation: 24661
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?
Upvotes: 25
Views: 50046
Reputation: 6528
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();
Upvotes: 6
Reputation: 21
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();
Upvotes: 2
Reputation: 536
Store.loadData([],false);
This statement drop local cache and not send changes to server side
Upvotes: 52
Reputation: 19353
Ok, from what I understand you want to ignore changes to the local store and not send it to the server side. Have you tried using:
myStore.rejectChanges();
This method clears all outstanding changes on all modified records. This will reject all pending changes.
Upvotes: 1