PDA

View Full Version : check for changes



AssetWorks
15 Mar 2013, 8:16 AM
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

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?

Farish
15 Mar 2013, 9:05 AM
To the best of my knowledge:

if(store.getNewRecords().length > 0 || store.getModifiedRecords().length > 0 || store.getRemovedRecords().length > 0)
console.log("store records modified");

AssetWorks
15 Mar 2013, 11:09 AM
that does not work in my case. it does not even enter the if statement:((

Farish
15 Mar 2013, 2:09 PM
try:

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.

AssetWorks
16 Mar 2013, 1:29 AM
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 =D>