PDA

View Full Version : JsonStore.remove() will call DELETE recursively



Ranma13
21 May 2010, 2:05 AM
I have a JsonStore configured like this:


var store = new Ext.data.JsonStore({
restful: true,
writer: new Ext.data.JsonWriter(),
url: '/test',
idProperty: 'id',
fields:
[
'id',
'name'
]
});Now I'm trying to delete multiple records from it (assuming I already loaded it with data):


store.remove(store.getById(1));
store.removeAt(store.getById(2));
store.removeAt(store.getById(3));
However, instead of getting three DELETE calls, I get this instead:


DELETE http://localhost/1

DELETE http://localhost/1
DELETE http://localhost/2

DELETE http://localhost/1
DELETE http://localhost/2
DELETE http://localhost/3
Does anyone know why I'm getting these weird 'recursive' DELETE calls?

Condor
21 May 2010, 2:45 AM
You get this because:
a. The server hasn't replied to the DELETE request yet or
b. The server sent an invalid response to the DELETE request

ps. Wouldn't it be better to use the store in batch:true mode?

Ranma13
21 May 2010, 2:51 AM
I'm using restful:true, so batching is disabled.

I understand now that the problem occurs because the server hasn't responded to the previous DELETE requests yet (hence why the store tries to send it again the second time around). My workaround for now is to set autoSave: false and manually call store.save() after all the store.remove() calls, but if anybody knows of any other solutions, I'd be happy to hear them. It seems really odd that ExtJS doesn't handle this very common use case (multiple removes from one store with autoSave:true and restful:true).