Results 1 to 3 of 3

Thread: How to properly update instance of a model in a store using data from server?

  1. #1
    Sencha User
    Join Date
    Oct 2012
    Location
    Poland
    Posts
    70
    Answers
    4
    Vote Rating
    5
      0  

    Default Answered: How to properly update instance of a model in a store using data from server?

    I've got a model and a store. The main view submits all changes via store and its REST proxy using:

    Code:
    record.set({field: value})
    store.sync();
    However, I've got another view (form.Panel) and it does non-REST request using simply form.submit(). In this case server responds with JSON representation of the record (just like for REST requests). I'd like to update the instance of the record in the store with the received data and trigger all store events that would be called if it was received by the store (e.g. some views listen to "write" event to update its record). How to do it?

    Using record.set(data) marks it as dirty. Using record.setData(data) doesn't mark record as dirty, but then if I use view.setRecord(record), its updateRecord method is not called.

  2. Maybe:
    record.set(data);
    record.commit();

  3. #2
    Sencha User
    Join Date
    Nov 2012
    Location
    Netherlands
    Posts
    50
    Answers
    6
    Vote Rating
    1
      0  

    Default

    Maybe:
    record.set(data);
    record.commit();

  4. #3
    Sencha User
    Join Date
    Oct 2012
    Location
    Poland
    Posts
    70
    Answers
    4
    Vote Rating
    5
      0  

    Default

    Thanks! Somehow I overlooked it when looking through API docs.

Tags for this Thread

Posting Permissions

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