1. #1
    Sencha User kostysh's Avatar
    Join Date
    Nov 2011
    Location
    Odessa, Ukraine
    Posts
    166
    Vote Rating
    16
    kostysh will become famous soon enough

      0  

    Default How to update existing record in localstorage store

    How to update existing record in localstorage store


    Hi,
    I have problem with updating of existing record in localstorage store.
    Adding a new records with:

    store.add(newRecord);
    store.sync();

    - no problem.
    But if I try update already created record:

    var record = store.findRecord('id', createdId);
    record.set(updatedRecord); //updatedRecord is key-value object with new record

    - error:
    Uncaught TypeError: Cannot call method 'update' of undefined (in PR3 ST2)
    and
    Uncaught TypeError: Cannot read property 'isModel' of undefined (in PR2 ST2)

    Where it may be my mistake?

  2. #2
    Sencha - Senior Forum Manager mitchellsimoens's Avatar
    Join Date
    Mar 2007
    Location
    St. Louis, MO
    Posts
    33,666
    Vote Rating
    435
    mitchellsimoens has much to be proud of mitchellsimoens has much to be proud of mitchellsimoens has much to be proud of mitchellsimoens has much to be proud of mitchellsimoens has much to be proud of mitchellsimoens has much to be proud of mitchellsimoens has much to be proud of mitchellsimoens has much to be proud of mitchellsimoens has much to be proud of

      0  

    Default


    local storage has been a little broken. This will get fixed before way before GA
    Mitchell Simoens @SenchaMitch
    Sencha Inc, Senior Forum Manager
    ________________
    http://www.JSONPLint.com - Source to lint your JSONP!

    Check out my GitHub, lots of nice things for Ext JS 4 and Sencha Touch 2
    https://github.com/mitchellsimoens

    Think my support is good? Get more personalized support via a support subscription. https://www.sencha.com/store/

    Need more help with your app? Hire Sencha Services services@sencha.com

    Want to learn Sencha Touch 2? Check out Sencha Touch in Action that is almost in print!

    When posting code, please use BBCode's CODE tags.

  3. #3
    Sencha User kostysh's Avatar
    Join Date
    Nov 2011
    Location
    Odessa, Ukraine
    Posts
    166
    Vote Rating
    16
    kostysh will become famous soon enough

      0  

    Default


    hmm.. it is a pity
    perhaps there is a patch to fix the problem until the next release?

  4. #4
    Sencha Premium Member Martin1982's Avatar
    Join Date
    Aug 2011
    Location
    The Netherlands
    Posts
    109
    Vote Rating
    0
    Martin1982 is on a distinguished road

      0  

    Default


    Is there any other way to locally store data at the moment? I'm really in need of this

  5. #5
    Sencha - Sencha Touch Dev Team rdougan's Avatar
    Join Date
    Oct 2008
    Posts
    1,156
    Vote Rating
    4
    rdougan is on a distinguished road

      0  

    Default


    You'd have to implement your own version of it, which wouldn't be too difficult.
    Sencha Inc.
    Robert Dougan - @rdougan
    Sencha Touch 2 and Ext JS 4 Core Team Member, SASS/Theming Wizard.

  6. #6
    Sencha User
    Join Date
    Mar 2012
    Posts
    11
    Vote Rating
    0
    germallon is on a distinguished road

      0  

    Default


    I see there is no activity in this thread since December. Any updates on this?

  7. #7
    Sencha User kostysh's Avatar
    Join Date
    Nov 2011
    Location
    Odessa, Ukraine
    Posts
    166
    Vote Rating
    16
    kostysh will become famous soon enough

      0  

    Default


    All works fine for now

  8. #8
    Sencha User
    Join Date
    Mar 2012
    Posts
    11
    Vote Rating
    0
    germallon is on a distinguished road

      0  

    Default


    Perhaps I didn't explain myself correctly. Is there a way to update the localStorage records? Something along the lines of:

    record.update({fieldkey:fieldval, ...})?

    I know you can use record.setData({...}), but what if you have a record with several fields, and you are interested in updating only a few of those fields?

    Thank you in advance.

  9. #9
    Sencha User kostysh's Avatar
    Join Date
    Nov 2011
    Location
    Odessa, Ukraine
    Posts
    166
    Vote Rating
    16
    kostysh will become famous soon enough

      0  

    Default


    http://docs.sencha.com/touch/2-0/#!/...ore-method-add

    Code:
    storeObj.add({field: 'value'});
    storeObj.sync();// Or setup autoSync: true in store config

  10. #10
    Sencha User
    Join Date
    Mar 2012
    Posts
    11
    Vote Rating
    0
    germallon is on a distinguished road

      0  

    Default


    Quote Originally Posted by kostysh View Post
    http://docs.sencha.com/touch/2-0/#!/...ore-method-add

    Code:
    storeObj.add({field: 'value'});
    storeObj.sync();// Or setup autoSync: true in store config
    Correct me if I'm wrong, but your code snippet adds a new record to the store. It does not update an existing record.