View Full Version : JSON Store not sending "destroy" to server on remove

22 Sep 2009, 10:57 AM
I have a JSON store associated with a GridPanel which has a RowEditor.

If I select a row and delete it I get a "destroy" request sent to the server.

If I create a new row I get a "create" request sent to the server.

However, if I create a record and then delete it, I only get the "create" request, the "destroy" is never sent to the server.

I verified the store remove() is being executed and I verified the record is in the store before the remove is called.

So why wouldn't a store send a 'destroy' on a remove()?

22 Sep 2009, 1:28 PM
I figured out that the reason the "destroy" does not go back to the server is the store doesn't think the record has been modified. It thinks it's a 'phantom' record, but the 'create' has already been sent to the server. Anyway to force the store to go to the server with a 'destroy'?

22 Sep 2009, 1:59 PM
Well, sort of found a fix, but then it broke something else.

If I do the following before calling store.remove(r) then the server gets a 'destroy' request.

r.phantom = false;
r.id = r.get("key");

setting one or the other on the record wasn't enough, I had to set both the phantom and the id.

However, after this the roweditor no longer works. Oy:-(

22 Sep 2009, 3:00 PM
Got the last problem fixed, whew!

I had to do this before calling editor.startEditing(0);

editor.editing = false;

Mike Robinson
23 Sep 2009, 11:06 AM
(scratch... scratch... scratch...)

That "solution" seems strange to me. If the Store sent a "create" request to the host, and got back a response that it properly understood, then the records (I think...) would no longer be "phantom."

If they are still "phantom," then this strongly suggests to me that something is wrong with that response. I suggest that you closely examine the actual JSON/XML interactions that took place on that round-trip, and check very carefully that your ExtJS options correctly match it.