Results 1 to 4 of 4

Thread: Updating a stored item replicates index key - Sencha Touch 1.0

  1. #1

    Default Updating a stored item replicates index key - Sencha Touch 1.0

    Hi all,

    I'm not sure if this behaviour is by design or a bug but when I update a stored record/item the item key seems to repeatedly append to the indexer value.

    To update a record/stored item I'm using the following code:

    var storeItem = myComponent.store.getById(373557);
    storeItem .set('test', "hello in there");
    //store.dirty = true;
    storeItem.store.sync();

    //model
    Ext.regModel("Conversation", {
    fields: [
    { name: "id", type: "int" },
    { name: "test", type: "string" }]
    });

    //store
    Ext.regStore('Conversations', {
    model: 'Conversation',
    storeId: 'conversationsStore',
    autoLoad: true,
    autoSave: true //tried on and off, didn't make a difference
    });


    Viewing local storage files in Google Chrome I see that the value in key conversations-373557 is set correctly, however the value for the indexer conversations is '373557,373557,373557'. (Here I've updated a value in the record/item twice)

    Each time I update the record/item and sync it the id for my record/item is appended to the indexer.

    Indexer.png

    Does anyone know if this is a bug, by design or am I doing something wrong?

    thanks

    Francesco

  2. #2
    Sencha User
    Join Date
    Sep 2011
    Posts
    31

    Default same problem

    hey I'm working on a similar problem now, did you ever figure it out?

  3. #3
    Sencha User
    Join Date
    Mar 2011
    Posts
    2

    Default

    Me too. Did you ever get anywhere with it?

  4. #4

    Default

    Hi guys, stopped using the sencha stores and just wrote my own JSON serializer/de-serializer to local storage.

    Here are my utility methods:

    Code:
     saveData : function(key, data, asJSON) {
    			if (!Ext.isDefined(asJSON))
    				asJSON = false;
    			localStorage.setItem(localStoragePrefix + key, (asJSON)
    							? Ext.util.JSON.encode(data)
    							: data);
    		},
    
    
    		getData : function(key, asJSON) {
    			if (!Ext.isDefined(asJSON))
    				asJSON = false;
    			var data = localStorage.getItem(localStoragePrefix + key);
    			if (data != null && asJSON)
    				data = Ext.util.JSON.decode(data);
    			return data;
    		},
    
    
    		deleteData : function(key) {
    			localStorage.removeItem(localStoragePrefix + key);
    		},
    
    
    		clearAllData : function() {
    			var keyLength = localStoragePrefix.length;
    			console.log(keyLength);
    			for (key in localStorage) {
    				console.log(localStorage);
    				if (key.substring(0, keyLength) === localStoragePrefix)
    					localStorage.removeItem(key);
    			}
    		}
    cheers

    Francesco

Similar Threads

  1. Replies: 10
    Last Post: 20 Jan 2012, 10:10 AM
  2. Sencha Touch on iPhone v1 / iPod touch v1 ?
    By palnap in forum Sencha Touch 1.x: Discussion
    Replies: 4
    Last Post: 28 Oct 2010, 5:30 PM
  3. Replies: 2
    Last Post: 9 Sep 2010, 10:24 AM
  4. Updating TreePanel item on manual tree store item change
    By HerrB in forum Ext GWT: Discussion
    Replies: 0
    Last Post: 29 Jun 2009, 8:02 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •