【问题标题】:How to Apply Sorting on Selection column in DevExtreme Grid?如何对 DevExtreme Grid 中的选择列应用排序?
【发布时间】:2018-09-26 09:52:09
【问题描述】:

我在C# MVC 中使用DevExtreme Grid 在视图中显示数据。现在我想在第一列即Selection 列上应用sorting 功能,如下图所示。

现在,我需要使选择列可排序(选中和未选中)。意味着当用户第一次点击标题时,它将首先显示所有选定的行,然后是未选定的行,反之亦然。

任何帮助将不胜感激!

谢谢

【问题讨论】:

  • 由于“select”列不是数据列,因此不能按该列对数据进行排序。

标签: javascript jquery asp.net-mvc devextreme devexpress-mvc


【解决方案1】:

我正在寻找一种方法来做到这一点, 我在devexpress support center找到了这张票

正如您在示例中看到的,他们使用 javascript 函数进行自定义排序:

sortingMethod(value1: any, value2: any) {
  var isSelected1 = this.dataGrid.instance.isRowSelected(value1),
      isSelected2 = this.dataGrid.instance.isRowSelected(value2);

  if(isSelected1 && !isSelected2) return -1;
  if(!isSelected1 && isSelected2) return 1;

  return 0;
}

并且在“CustomerId”列中刚刚使用了上面的函数

<dxi-column 
      dataField="CustomerId"
      sortOrder="asc"
      [visible]="false"
      [sortingMethod]="sortingMethod"
      ></dxi-column>

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2020-06-21
    • 1970-01-01
    • 2020-07-20
    • 1970-01-01
    • 1970-01-01
    • 2021-01-24
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多