Page 1 of 2 12 LastLast
Results 1 to 10 of 13

Thread: How to update existing record in localstorage store

  1. #1
    Sencha User kostysh's Avatar
    Join Date
    Nov 2011
    Location
    Odessa, Ukraine
    Posts
    176

    Default 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 Premium User mitchellsimoens's Avatar
    Join Date
    Mar 2007
    Location
    Gainesville, FL
    Posts
    40,379

    Default

    local storage has been a little broken. This will get fixed before way before GA
    Mitchell Simoens @LikelyMitch

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

    Posts are my own, not any current, past or future employer's.

  3. #3
    Sencha User kostysh's Avatar
    Join Date
    Nov 2011
    Location
    Odessa, Ukraine
    Posts
    176

    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

    Default

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

  5. #5
    Sencha User rdougan's Avatar
    Join Date
    Oct 2008
    Posts
    1,159

    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

    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
    176

    Default

    All works fine for now

  8. #8
    Sencha User
    Join Date
    Mar 2012
    Posts
    11

    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
    176

    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

    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.

Page 1 of 2 12 LastLast

Posting Permissions

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