PDA

View Full Version : How to remove records from the getRemovedRecords() in a store



marxan
30 May 2013, 12:55 AM
Hello,

I have a store filled with data when ticking on a checkbox. What I do so far: when I untick the checkbox, it removes the value in the store and when I tick it again, instead of loading the data through an ajax call, I retrieve it in the getRemovedRecords() and put it again in my store.
The problem is the value is not remove from the getRemovedRecords() so if I do it a second time (untick and tick), the records appears twice in the store and so on...

Is there a way to remove the record from the getRemovedRecords that I've just loaded to avoid this behaviour?

Thanks,

Marxan

friend
30 May 2013, 9:42 AM
Removed records are managed by the store, where calling sync() instructs the store's proxy to pass any deletes back to the server. In a nutshell, you're stepping on ExtJs's native lifecycle management of records in the store, where this isn't a good idea.

Instead of physically deleting the records from the store, you could do a 'soft delete', then use a filter to hide the target records. The 'soft delete' would involve you adding a new column to the store named something like 'softDelete'. When the checkbox is ticked, you update the target record's 'softDelete' field with a value of 1, then apply a filter to hide all records where all softDelete == 1. Obviously, this would force you to manually handle sending deletes to the server-side, but that's the price you pay...

Otherwise, just bite the bullet and reload the store via an Ajax call. This is the simplest/easiest method of them all and unless your app is extremely bandwidth constrained, it's a good idea all the way around.

marxan
11 Jun 2013, 4:04 AM
Thanks, I'm using your softdelete explanation and it works fine.