-
29 Dec 2010 5:54 AM #1
Store.remove using LocalStorage proxy not working for me
Store.remove using LocalStorage proxy not working for me
My app periodically refreshes a data store of employee records using a LocalStorage proxy. Each refresh, if I call the remove method on entire record range, it does not remove the records (at least synchronously), and then will cause records to be duplicated each refresh (1x, 2x, 3x, 4x, etc.). What I did as a workaround was access localStorage object directly to remove the data and then reload store from localStorage.
This is a code excerpt:
Is this an issue of asynchronous removal? What is the correct way to do this within Sencha API?Code:TC.DeleteLocalStorageThatBeginsWith('tcEmployeeCache'); //TC.employeeCache.remove(TC.employeeCache.getRange()); // not removing records for some reason TC.employeeCache.load(); TC.employeeCache.add(pingResult.employees); TC.employeeCache.sync(); TC.DeleteLocalStorageThatBeginsWith = function(keyPrefix){ var len = localStorage.length; // reverse iterate collection to allow inline removal for(var i = len-1; i >= 0; i--){ var key = localStorage.key(i); if(key.indexOf(keyPrefix) == 0){ localStorage.removeItem(key); } } }
Thanks.
-
30 Dec 2010 1:21 PM #2
-
30 Dec 2010 1:41 PM #3
You are absolutely correct! Adding an id fixed the problem. Looks like a Sencha bug, either in code or in documentation of the 'id' field.
Similar Threads
-
NestedList: Can TreeStorage + localstorage proxy be used?
By igaenssley in forum Sencha Touch 1.x: DiscussionReplies: 0Last Post: 25 Oct 2010, 9:46 AM -
[FIXED-328] store.loadData + store.sync does not update the index on the localStorage
By axxerion in forum Sencha Touch 1.x: BugsReplies: 4Last Post: 25 Sep 2010, 11:29 AM -
How To sync store / proxy / Model with "submodel" and localstorage
By hq242 in forum Sencha Touch 1.x: DiscussionReplies: 0Last Post: 30 Jul 2010, 5:58 AM -
[CLOSED][3.0] Focusing cell in grid - performance degrades
By pharod in forum Ext 3.x: BugsReplies: 2Last Post: 27 Oct 2009, 9:05 PM -
Grid performance degrades linearly with the number of row selections
By lenau0 in forum Ext 2.x: Help & DiscussionReplies: 9Last Post: 10 Feb 2009, 6:11 AM


Reply With Quote