Results 1 to 4 of 4

Thread: Updating record with new data

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Sencha Premium Member
    Join Date
    May 2012
    Vote Rating

    Default Answered: Updating record with new data


    I have a store of models downloaded to display in a grid. After double clicking a row, model is taken for edit in a separate window. However to edit such model, i need to populate it with additional data, as what server gives me to display in grid context is incomplete.
    Does anyone know a way how to update the same model with a data from new url?
    It's sort of like this: Model downloaded in grid's context (from some list api) with only some data -> model checked out for edition -> model updating itself from get single model api (server sends all the data that i don't , yet, have) -> user's edit -> save.

    I could use two separate objects, sure, but then the server has to send me all the information in the single api, while i have some already from list, which I'm trying to avoid.
    And I can't copy info from old model to new model either, because if there was a change by another user in one of the fields I already have, server would send me also those data, and I'd then overwrite them with the old ones -> that's not desired.

    I've already did some research on this, noticed the model's private copyFrom method. Problem is however, that it copies all the fields, even those that are set to default vales because server didn't send them. So in result I have incomplete/falsy info.
    To fix this, I've went trough the reader and noticed that default values aren't applied if operation is not "read", so then there would be no entry in dataProperty and model's copyFrom would work as desired, but when i set it to something else than read it fails, because it tries to write some data which are just not there (and it's not desired to write the data anyway)

    Aaand now I'm out of ideas. Hint, anyone?

  2. When you load a store, it will load the data and create instances of the model. If you load a model, it will create a single instance of that model. If you sync the store it will send the changes to the server and you can then return the updated data. If you save a model it will save that single instance. IMO it gets messy if you don't use one entry point.

Posting Permissions

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