Click here to Skip to main content
15,886,362 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hello,

I have a requirement like I have on Kendo Grid and and I have to do two things with that

1.Getting KendoGrid datasorce.
2.After getting the datasource I have to sort some of the rows in that data source.


I am getting the datasource like

JavaScript
var dataSource = $("#" + gridId).data().kendoGrid.dataSource.data();


but I am not able to sort it any way

I have used the following process to do that

C#
dataSource = new kendo.data.DataSource({
            data: dataSource,
            sort: { field: "Column1", dir: "desc" }
        });

        dataSource = dataSource.view();


But it was worst trying.

Waiting for the reply.

Thanks
Ipsita
Posted

1 solution

The way I've seen to get a Kendo DataSource from a Grid is like this:
JavaScript
var ds = $("#grid").data("kendoGrid").dataSource;

Once you have the DataSource in a variable, you can simple run .sort() on it and pass in a sort object:
JavaScript
ds.sort({ field: "fieldName", dir: "asc" });
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900