PDA

View Full Version : Store.rejectChanges() + phantom records



Jonny5
18 Jun 2010, 1:48 PM
I notice that Store.rejectChanges() only reverts deleted and modified records but not newly added records. How can one also reject newly added records? The goal here is to revert all pending changes in-case an error occurs during the commit operation.

I have tried the following code snippet, but it is broken. It will remove any record that was previously a phantom record since the last page refresh regardless of whether it was successfully committed to the server or not. Maybe this is another bug? such as a failure to set record.phantom = false after a successful commit?


store.rejectChanges();
store.each(function(r){
if(r.phantom){
store.remove(r);
}
});

So has anyone come across a solution?

darthwes
18 Jun 2010, 9:52 PM
store.load()?

Condor
18 Jun 2010, 10:41 PM
You not only need to remove phantom records, you also need to restore deleted records.

But I agree with darthwes: If you already have an error than the best solution is to refresh the data completely.

Jonny5
21 Jun 2010, 9:49 AM
Currently store.load() is what I am using to work-around this issue. I am looking for a solution that avoids making another HTTP request.