This is a migrated thread and some comments may be shown as answers.

Get Sorted Items without Paging

2 Answers 564 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Michalis
Top achievements
Rank 1
Michalis asked on 13 Dec 2012, 10:43 AM
hi,

Is there any way to programmatically get the datasource in a grid with the items sorted as the user has selected?

The following:

$(grid).data("kendoGrid").dataSource.view()

takes into account grid paging also, and does not return the items of the entire datasource sorted. Can I get somehow all dataitems sorted regardless of paging?

Thanks in advacne

2 Answers, 1 is accepted

Sort by
0
Daniel
Telerik team
answered on 15 Dec 2012, 08:11 AM
Hello Michalis,

The dataSource does not keep a sorted collection separately. In order to get the ordered data for all pages you should perform the sorting on the dataSource observable array which can be found through the data method. The Kendo Query could be used for that purpose e.g.

var grid = $("#grid").data("kendoGrid");
var dataSource = grid.dataSource;
var data = dataSource.data();
var sort = dataSource.sort();
var query = new kendo.data.Query(data);
var sortedData = query.sort(sort).data;
Kind regards,
Daniel
the Telerik team
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
0
Michalis
Top achievements
Rank 1
answered on 17 Dec 2012, 04:27 PM
hi Daniel,

Thanks, that worked perfectly.
Tags
Grid
Asked by
Michalis
Top achievements
Rank 1
Answers by
Daniel
Telerik team
Michalis
Top achievements
Rank 1
Share this question
or