简体   繁体   English

Kendo UI网格-升序排序

[英]Kendo UI Grid - Sort by Descending Before Ascending

I've read through every online post I could find about about sorting with the Kendo Grid. 我已经阅读了所有有关使用Kendo Grid进行排序的在线文章。 Basically I'm trying to find a way to sort by descending first and then ascending after. 基本上,我试图找到一种排序方式,先降序然后升序。 I know how to set a default sort as descending when the grid loads, but I need this to happen any time a field is sorted. 我知道如何在网格加载时将默认排序设置为降序,但是我需要在对字段进行排序时进行这种排序。 If there is no sort, it should sort by descending first. 如果没有排序,则应先降序排序。

  sortable: {
            allowUnsort: false
            SortByDescendingFirst: true <== Something like this
        },

I don't think there's an option to define that - you can try something like this (this is for Q1 2014, in older versions you can do the same but you have to modify kendo.ui.Sortable.fn._click instead): 我认为没有定义该选项的选项-您可以尝试这样的操作(这是针对2014年第1季度的,在较早的版本中,您可以执行相同的操作,但必须修改kendo.ui.Sortable.fn._click ):

kendo.ui.Sorter.fn._click = function (originalFn) {
    return function (e) {
        var element = this.element,
            dir = element.attr(kendo.attr("dir"));

        if (!dir) element.attr(kendo.attr("dir"), "asc");
        if (dir === "desc") element.attr(kendo.attr("dir"), "");
        if (dir === "asc") element.attr(kendo.attr("dir"), "desc");

        originalFn.call(this, e);
    };
}(kendo.ui.Sorter.fn._click);

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM