Results 1 to 4 of 4

Thread: Proper way to update locale storage entries without duplicating the key entries

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Sencha User
    Join Date
    Aug 2012
    Posts
    68
    Answers
    3

    Default Proper way to update locale storage entries without duplicating the key entries

    Hi there,

    I would like to know what is the proper way to update the entries of the localstorage without having the key entries duplicated.

    Suppose we have the store "module". The model used for this store has two boolean fields "isnew" and "isupdated" and the id field which is int.

    Suppose we have this situation in the local storage:

    module: 4,5
    module-4: {id: 4, isnew: true, isupdated: true}
    module-5: {id: 5, isnew: true, isupdated: true}

    Now. If I use this code:

    Ext.data.StoreManager.lookup('modules').getById(5).set('isnew', false):
    Ext.data.StoreManager.lookup('modules').sync();

    I end up with this situation:

    module: 4,5,5
    module-4: {id: 4, isnew: true, isupdated: true}
    module-5: {id: 5, isnew: false, isupdated: true}

    As you can see the key entry 5 is repeated.

    Do I have to remove the entry 5 first and then add it again? Why this even happens?

    It seems to me that this happens every time that the setDirty() function is called. But without calling the setDirty() or set() function the localstorage is not updated at all.

    I really need to understand this well because it is driving me crazy.

  2. #2
    Sencha Premium User mitchellsimoens's Avatar
    Join Date
    Mar 2007
    Location
    Gainesville, FL
    Posts
    40,388
    Answers
    3997

    Default

    What ST2 version are you using?
    Mitchell Simoens @LikelyMitch
    Modus Create, Senior Frontend Engineer
    ________________
    Need any sort of Ext JS help? Modus Create is here to help!

    Check out my GitHub:
    https://github.com/mitchellsimoens

  3. #3
    Sencha User
    Join Date
    Aug 2012
    Posts
    68
    Answers
    3

    Default

    Quote Originally Posted by mitchellsimoens View Post
    What ST2 version are you using?
    sencha-touch-2.0.1.1

  4. #4
    Sencha User
    Join Date
    Aug 2012
    Posts
    68
    Answers
    3

    Default

    So...is there any solution to this issue?

Posting Permissions

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