dojojsonreststore

dojo 1.10 JsonRest idAttribute - server passed a float in PUT


Just getting started with dojo/JsonRest, but having some problems with sending updates back to my server. I've got 2 questions that I'm stuck with;

The code below produces a grid with one of the columns set to editable. The primary key in my json data is the "jobName" attribute (hence idAttribute in the JsonRest store).

First question is about the URI in the PUT; - When I call dataStore.save() the server get's a PUT, but the URI is /myrestservice/Jobs/0.9877865987 (it changes each time, but is always a float) - I don't see where dojo is getting the float number from? It's not my idAttribute value from that row. How can I get the PUT to respect the idAttribute in the JsonRest store? - I did try setting idProperty in the MemoryStore to "jobName", but that changed the PUT in to a POST and removed the float, but I still don't get a jobName in the URI which is what my REST server needs.

Second question about the content of the PUT; - The PUT contains the whole row. I'd really just like the idAttribute and the data that changed - is that possible?

I've been through the examples and docs, but there aren't many examples of handling the PUT/POST part of JsonRest.

Thanks

    var userMemoryStore = new dojo.store.Memory( );
    var userJsonRestStore = new dojo.store.JsonRest({target:"/myrestservice/Jobs/", idAttribute:"jobName"});
    var jsonStore = new dojo.store.Cache(userJsonRestStore, userMemoryStore);
    var dataStore = new dojo.data.ObjectStore( {objectStore: jsonStore } );

    /*create a new grid*/
    var grid = new dojox.grid.DataGrid({
        id: 'grid'
        ,store: dataStore
        ,structure: layout
        ,rowSelector: '20px'}
        ,"gridDiv");

    grid.startup();
    dojo.query("#save").onclick(function() {
                    dataStore.save();
                });

Solution

  • I think you want idProperty, not idAttribute. It also might help to set idProperty in the Memory store being used to cache as well; that may be what's generating the random float.

    As for the second question, that'd probably require customization; I don't believe OOTB stores (or grids) generally expect to send partial items.