1. #1
    Sencha Premium Member
    Join Date
    Jan 2013
    Posts
    64
    Answers
    6
    Vote Rating
    5
    AssetWorks is on a distinguished road

      0  

    Default Answered: check for changes

    Answered: check for changes


    I guess my question would be what is the best way to track whether or no a data in a store as changed since it was loaded
    the catch here is that I have other stores associated to that store.
    so I can do
    Code:
    store.getData(true)
    and that will return every field and value as an Object but how can I check if that value has been changed since it has been loaded.
    I could also do a nested store.each and check if record isModified()
    but it all comes down to my original question.

    What is the Best Way to do it?

  2. To the best of my knowledge:
    Code:
    if(store.getNewRecords().length > 0 || store.getModifiedRecords().length > 0 || store.getRemovedRecords().length > 0)
      console.log("store records modified");

  3. #2
    Touch Premium Member
    Join Date
    Jun 2011
    Posts
    1,088
    Answers
    112
    Vote Rating
    95
    Farish is a glorious beacon of light Farish is a glorious beacon of light Farish is a glorious beacon of light Farish is a glorious beacon of light Farish is a glorious beacon of light

      0  

    Default


    To the best of my knowledge:
    Code:
    if(store.getNewRecords().length > 0 || store.getModifiedRecords().length > 0 || store.getRemovedRecords().length > 0)
      console.log("store records modified");

  4. #3
    Sencha Premium Member
    Join Date
    Jan 2013
    Posts
    64
    Answers
    6
    Vote Rating
    5
    AssetWorks is on a distinguished road

      0  

    Default


    that does not work in my case. it does not even enter the if statement

  5. #4
    Touch Premium Member
    Join Date
    Jun 2011
    Posts
    1,088
    Answers
    112
    Vote Rating
    95
    Farish is a glorious beacon of light Farish is a glorious beacon of light Farish is a glorious beacon of light Farish is a glorious beacon of light Farish is a glorious beacon of light

      0  

    Default


    try:
    Code:
    console.log(store.getNewRecords());
    console.log(store.getModifiedRecords());
    console.log(store.getRemovedRecords());
    this should show 3 arrays in the console. if the arrays are empty, that would mean your store has no records to sync. you can also check the documentation of these functions.

  6. #5
    Sencha Premium Member
    Join Date
    Jan 2013
    Posts
    64
    Answers
    6
    Vote Rating
    5
    AssetWorks is on a distinguished road

      0  

    Default


    Actually that did work for me, I was not doing an update records in my form so values never got updated in my model therefore it was not registering that store had modifications

    Thanks a lot

Thread Participants: 1

Tags for this Thread