views:

575

answers:

1

I have a JsonStore configured like so:

var store = new Ext.data.JsonStore({
    restful: true,
    url: '/categories',
    remoteSort: true,
    idProperty: 'Id',
    totalProperty: 'total',
    root: 'results',
    writer: new Ext.data.JsonWriter({
        encode: false
    }),

    fields: [ 'Id', 'Name' ]
});

I grab some data from the server, then edit one of the records. When I tell the store to save, it sends this JSON back to the server:

{
    "results":
    {
        "Name":"Trivial123",
        "Id":2
    }
}

The store is wrapping the JSON inside the results property (the root property configured on the store). However, the server expects this:

{
    "Name":"Trivial123",
    "Id":2
}

In other words, the serialized entity should be put directly in the response body, and not wrapped in a property. Does anyone know how I can configure the store to do this?

A: 

I'm assuming you can't just not set the root value for the store for some reason? That's the way I normally do it.

Jim Barrows
The JSON I get from the server has the actual data put in the `results` property. You just gave me an idea though that I'm going to try out.
Daniel T.