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

Sort field on column

1 Answer 545 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Alanm
Top achievements
Rank 2
Alanm asked on 14 Dec 2015, 04:59 PM
Can I set a different sort field on a column, so when I click 'sort' on the "Name" column it sends the field "Surname" to the server in the sort query. Like SortExpression on the RadGrid?

1 Answer, 1 is accepted

Sort by
0
Kostadin
Telerik team
answered on 16 Dec 2015, 09:09 AM
Hello Alanm,

Thank you for contacting us.

Generally you can get the sort configuration and modify it the way you want. Please check out the following code snippet which demonstrates how to access the sort expressions.
// Get the grid object
var grid = $("#grid").data("kendoGrid");
// Get the datasource bound to the grid
var ds = grid.dataSource;
// Get current sorting
var sort = ds.sort();

After you get the sort collection you can add/remove sort objects from it.
var grid = $("#grid").data('kendoGrid');
var dsSort = [];
dsSort.push({ field: "fieldName1", dir: "asc" });
dsSort.push({ field: "fieldName2", dir: "desc" });
kendoGrid.dataSource.sort(dsSort);

I hope this information helps.

Regards,
Kostadin
Telerik
 
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
 
Tags
Grid
Asked by
Alanm
Top achievements
Rank 2
Answers by
Kostadin
Telerik team
Share this question
or