Sort field on column

2 posts, 0 answers
  1. Alanm
    Alanm avatar
    26 posts
    Member since:
    Mar 2007

    Posted 14 Dec 2015 Link to this post

    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?
  2. Kostadin
    Kostadin avatar
    1733 posts

    Posted 16 Dec 2015 Link to this post

    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" });

    I hope this information helps.

    Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
Back to Top