1
votes

I'm using a Kendo DataGrid and want to programmatically set the sort and the group of its datasource without it making 2 separate network calls to get the data. The datasource is using a Web API OData URL, serverPaging, serverFiltering, serverSorting are all set to true.

The following results in 2 separate network calls:

grid.dataSource.sort([{ field: "Name", dir: "asc" }]);
grid.dataSource.group([{ "field": "Region", "dir": "asc" }]);

Is there any way to achieve a programmatic sorting/grouping in a single request?

2
I don't really known KendoUI but perhaps a solution is to define a OData-like analysis service using (server-side) the QueryByCube LINQ extension method provided by AdaptiveLINQ. Disclaimer: I'm the AdaptiveLINQ developer. - nlips

2 Answers

3
votes

Use the query method of the data source:

dataSource.query( { 
 sort: [ /* sort descriptors */], 
 group: [ /* group descriptors */ ], 
 page: dataSource.page(), 
 pageSize: dataSource.pageSize() 
});
0
votes

My syntax was a little different but it work well

datasource.query({
    sort: { field: "Sort", dir: "asc"},
    group: { field: "CategoryName" },
    pageSize: 50
});