PDA

View Full Version : Removing data from store but still left in proxy



infernoz
12 Apr 2013, 11:28 AM
Hello,

I have a grid with a store/ajax proxy associated with it. I allow the user to search for data and the data appears in the grid by passing json data back from the server. The user can make updates to that data and submit the data by my code calling store.sync().

I allow the user to remove data from the grid. I do this by calling store.removeAll or store.remove(range of model instances). This seems to remove the data from the store BUT the data removed seems to linger in the proxy. When I call store.getRemovedRecords() the records the user removed are returned.

The problem with this is that when a user makes additional updates and I call store.sync(), the records removed are seen as "Deleted" and attempt to sync up with the proxy. I dont want this behavior, rather, I'd like data that is removed from the grid, to be removed from the store/proxy and not be sent to the server after store.sync() is called.

How can I configure my grid, store, and proxy in this way?

Thanks,

infernoz

slemmon
15 Apr 2013, 10:16 AM
When the records are removed (http://docs.sencha.com/extjs/4.2.0/#!/api/Ext.data.Store-property-removed) from the store they're logged in the removed property of the grid. You might look into removing those records from the removed property after the remove/removeAll action if you don't want them included in the sync() to include those records when syncing to the server.

infernoz
15 Apr 2013, 1:24 PM
Thanks slemmon, I pretty much did that. I cleared out the the data from the store/proxy by calling store.load() and passing in an empty array. That overwrites the data that is in there but considered removed.

A related note to this, I see that up to 3 POST requests are sent to the server when store.sync() is called, one for updates, one for adds, and one for deletes. Is it possible to combine these record "changes" into 1 POST request? This would be ideal with my application.

Thanks,

infernoz

slemmon
15 Apr 2013, 2:57 PM
I'm afraid there's not a way to bundle the operations into a single transaction right from the framework. You'd have to create your own writer extension to gather up the modified, deleted, added records and sync them with your own method.

infernoz
16 Apr 2013, 8:57 AM
Ok, thanks slemmon