PDA

View Full Version : Reseting a model after a grid sync with 4.1



abcdef
11 May 2012, 12:29 PM
1. I have multiple grids, and the user can drag and drop records across these grids.
2. As the drop happens, I set a property - 'X' - depending on the store that the record was dropped into.
3. On pressing the 'Save' button, I initiate the 'sync' method.
4. If certain records don't commit successfully, I catch the exception and report it to the user.
5. Now, I'd like to reinstate these unsuccessful records back to the grids that the user dragged them from and reset the property 'X' back to its original value.


What is the best way to accomplish step 5? Thanks!

scottmartin
15 May 2012, 8:14 AM
Can you setup an array that holds the exception records and load them back into the store?

Regards,
Scott.

ghosh
15 May 2012, 9:13 AM
Can you setup an array that holds the exception records and load them back into the store?

Regards,
Scott.

Thanks for the reply!

Here is what I'm essentially doing right now:



store.proxy.on({
exception: function(proxy, response, operation) {
Ext.each(operation.records, function(record) {
if(!Ext.isEmpty(record)) {
store.remove(record);
record.reject();
originalStore.add(record);
}
});
}
});


I noticed that without record.reject(), the record remains dirty. It works for the most part, except that getRemovedRecords() on the originalStore still does return me the record even after add it to the store.

I guess I'm looking for an efficient way to bring the record and the original store back to their original states (as if nothing happened in between).