dojodgriddstore

Dojo dStore Rest dGrid sort parameter


When I fetch from a dStore the URL looks something like this

http://localhost/rest/dojo?department=sales

which works fine. If I then click in the header of the dGrid the sent URL looks like this.

http://localhost/rest/dojo?department=sales&sort(+id)&limit(25)

Shouldn't it send &sort=+id&limit=25? I am using Java and Spring for the backend and it expects the parameters to be formatted this way. Right now I can not receive the extra parameters. Is there a way to get it to send the parameters the way Spring is expecting them?


Solution

  • sort(...) and limit(...) are the default behaviors of dstore/Request (which Rest extends), but these can be customized via sortParam for sort, and useRangeHeaders or rangeStartParam and rangeCountParam for range.

    For example, to result in &sort=+id&limit=25 as you requested, you could set up your store as follows:

    var store = new Rest({
        target: '...',
        sortParam: 'sort',
        rangeStartParam: 'offset',
        rangeCountParam: 'limit'
    });
    

    I've additionally assumed above that offset is the GET parameter you'd want to use to indicate what record to start at when requesting ranges. Generally if you're not using range headers (useRangeHeaders defaults to false) and you want to set a count GET parameter, you'll also need to set a start GET parameter.

    These properties are listed in the Request Store documentation.