PDA

View Full Version : Update w/ RESTful Datastore



tfulmino
1 Jul 2009, 2:48 PM
I am trying to implement the RESTful Datastore and a grid. So far, I have been able to wire up the Get and Delete; however, the Update does not seem to be working. I have attached Fiddler to review the session... the only thing that stands out is the 'undefined' var in the querystring. Below is the raw request and the code I am using to create the Datastore / Proxy.

Thanks in advance!



PUT /service/inventoryservice.svc/inventory/automobiles/2 HTTP/1.1
Host: localhost:1244
User-Agent: Mozilla/5.0 (Windows; U; Windows NT 6.0; en-US; rv:1.9.0.7) Gecko/2009021910 Firefox/3.0.7 (.NET CLR 3.5.30729)
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
Accept-Language: en-us,en;q=0.5
Accept-Encoding: gzip,deflate
Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7
Keep-Alive: 300
Connection: keep-alive
X-Requested-With: XMLHttpRequest
Content-Type: application/x-www-form-urlencoded; charset=UTF-8
Referer: http://localhost:1244/Default.aspx
Content-Length: 89

AutomobileID=2&undefined=%7B%22Make%22%3A%22Mercedes%20Ben%22%2C%22AutomobileID%22%3A2%7D


// Create a standard HttpProxy instance.
var proxy = new Ext.data.HttpProxy({
url: 'http://localhost:1244/service/inventoryservice.svc/inventory/automobiles'
});

// Typical JsonReader. Notice additional meta-data params for defining the core attributes of your json-response
var reader = new Ext.data.JsonReader({
idProperty: 'AutomobileID'
},
[
{ name: 'AutomobileID' },
{ name: 'Make', allowBlank: false },
{ name: 'Model', allowBlank: false }
]);

// The new DataWriter component.
var writer = new Ext.data.JsonWriter();

// Typical Store collecting the Proxy, Reader and Writer together.
var store = new Ext.data.Store({
id: 'Automobile',
restful: true, // <-- This Store is RESTful
proxy: proxy,
reader: reader,
writer: writer, // <-- plug a DataWriter into the store just as you would a Reader
listeners: {
write: function(store, action, result, response, rs) {
//App.setAlert(response.success, response.message);
}
}
});