1. #1
    Sencha Premium Member
    Join Date
    May 2012
    Posts
    29
    Vote Rating
    2
    tkolo is on a distinguished road

      0  

    Default Answered: Updating record with new data

    Answered: Updating record with new data


    Hi,

    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.

  3. #2
    Sencha - Senior Forum Manager mitchellsimoens's Avatar
    Join Date
    Mar 2007
    Location
    Gainesville, FL
    Posts
    36,633
    Answers
    3452
    Vote Rating
    818
    mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute

      0  

    Default


    You really need to only use one entry point to get your data.
    Mitchell Simoens @SenchaMitch
    Sencha Inc, Senior Forum Manager
    ________________
    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 in print!

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

  4. #3
    Sencha Premium Member
    Join Date
    May 2012
    Posts
    29
    Vote Rating
    2
    tkolo is on a distinguished road

      0  

    Default


    Isn't it whole purpose of stores having separate proxy config to have separate data controller for them?

  5. #4
    Sencha - Senior Forum Manager mitchellsimoens's Avatar
    Join Date
    Mar 2007
    Location
    Gainesville, FL
    Posts
    36,633
    Answers
    3452
    Vote Rating
    818
    mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute

      1  

    Default


    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.
    Mitchell Simoens @SenchaMitch
    Sencha Inc, Senior Forum Manager
    ________________
    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 in print!

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

Thread Participants: 1