1. #1
    Sencha Premium Member
    Join Date
    Jul 2009
    Posts
    116
    Vote Rating
    0
    JacobGu is on a distinguished road

      0  

    Default 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:

    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);
    		}
    	}
    }
    Is this an issue of asynchronous removal? What is the correct way to do this within Sencha API?

    Thanks.

  2. #2
    Sencha User
    Join Date
    Apr 2010
    Posts
    4
    Vote Rating
    0
    chummy is on a distinguished road

      0  

    Default


    My reply to this thread (http://www.sencha.com/forum/showthre...ngs-and-remove) might help.

    Chummy

  3. #3
    Sencha Premium Member
    Join Date
    Jul 2009
    Posts
    116
    Vote Rating
    0
    JacobGu is on a distinguished road

      0  

    Default


    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

  1. NestedList: Can TreeStorage + localstorage proxy be used?
    By igaenssley in forum Sencha Touch 1.x: Discussion
    Replies: 0
    Last Post: 25 Oct 2010, 9:46 AM
  2. Replies: 4
    Last Post: 25 Sep 2010, 11:29 AM
  3. How To sync store / proxy / Model with "submodel" and localstorage
    By hq242 in forum Sencha Touch 1.x: Discussion
    Replies: 0
    Last Post: 30 Jul 2010, 5:58 AM
  4. Replies: 2
    Last Post: 27 Oct 2009, 9:05 PM
  5. Grid performance degrades linearly with the number of row selections
    By lenau0 in forum Ext 2.x: Help & Discussion
    Replies: 9
    Last Post: 10 Feb 2009, 6:11 AM

Thread Participants: 1