PDA

View Full Version : Ext 3.1 EditorGridPanel and JSON/REST where remote CUD does not return data



jmaasing
3 Jan 2010, 4:35 AM
I'm struggling to use the EditorGridPanel in Ext 3.1 with a server side that does not return JSON data for PUT, POST or DELETE.

I have an Ext.data.Store configured with (subclasses) of JsonWriter and JsonReader and restful: true.

For 'create' (POST) I add a new record to the store. The record gets added to the store, flagged as dirty, and with a phantom ID. There is a call to the server side that inserts the data into the database. The server respons is NOT json but rather some HTML and the location-header set to the new resource. Because of this Ext does not know how to replace the phantom ID and flag the record as not dirty.

So my question is; where should I override Ext to create a record ID from the Http-response?

Now, I have 'update' (PUT) working by subclassing JsonReader and overriding readResponse to simply look at the HttpStatus code and setting the successProperty, like this:


readResponse : function(action, response) {
var o = {};

if (response.status >= 200 && response.status <= 300) {
o[this.meta.successProperty] = true;
However, readResponse seems not to be called for POST otherwise I could have faked the record ID in a similar way to make the DataReader#realize work.

Cheers,
Johan

jmaasing
19 Jan 2010, 6:05 AM
This is a related discussion about some of the assumptions Ext makes for REST (i.m.o Ext makes to much assumptions).

http://www.extjs.com/forum/showthread.php?t=72623