4

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?

bobmanc
  • 57
  • 6

1 Answers1

3

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.

Ken Franqueiro
  • 10,559
  • 2
  • 23
  • 40
  • I'm not positive but I don't think this answers my question. The parameters do include "sort" and "limit" that's not this issue. My problem is the format of the URL. There 's no "=" between the parameters and the values. See the second URL above. It currently sends "sort(+id)" and not "sort=+id". – bobmanc Oct 24 '15 at 21:06
  • 1
    I suppose I could've been more clear about the default behaviors of `Request`, which are to use `sort(...)` and `limit(...)` if none of the `Param` properties are set. Once you use the `Param` properties, `Request` changes its behavior to sending standard key/value pairs, using the `Param` property settings as the keys. Give it a try. – Ken Franqueiro Oct 24 '15 at 21:18
  • This does seem confusing to me though. I would think the default format would be the way I described it. I have never seen it done the other way. Also by specifying the sortParam I would expect that to change the name of the param only. There is no indication that the format will also change by specifying a name. – bobmanc Oct 28 '15 at 13:53