Default sort direction of kendo grid is ascending when we click on header column.
I want to sort kendo grid in descending order when user click on header first time.
Example:
1. Default Behavior
Studnet Marks
abc 15
pqr 25
xyz 7
2. When Clicking on Marks Header first time
Student Marks
pqr 25
abc 15
xyz 7
3. When clicking on Marks header second time.
Students Marks
xyz 7
abc 15
pqr 25
I am tring something like this:
$("#priority .k-header").eq(1).click(function(ele) {
debugger;
var kendoGrid = $("#priority").data('kendoGrid');
var dsSort = [];
var sort = kendoGrid.dataSource.sort();
if (sort.length > 0) {
if(sort[0].dir==="asc")
kendoGrid.dataSource.sort({field: sort[0].field, dir: "desc"});
if(sort[0].dir==="desc")
kendoGrid.dataSource.sort({field: sort[0].field, dir: "asc"});
}
});
But it does not work.