AG Grid - 使用键而不是值对列进行排序

AG Grid - Sorting a column with key and not Value

我正在寻找机会使用键而不是显示的值对列进行排序,但我找不到执行此操作的方法。

我正在这样加载数据:

[{key: 1, name: 'Microsoft'}, {key: 2, name: 'Apple'}, {key: 3, 'IBM'}]

现在列的排序方式如下:

'Apple'
'IBM'
'Microsoft'

但我想要这样排序并且网格中没有列 "key":

'Microsoft'
'Apple'
'IBM'

我想我需要使用自定义排序,但不知道如何开始。

任何帮助都是有用的。

提前致谢。

columnDefs中添加comparator喜欢-

var columnDefs = [
  {
    headerName: 'Company', 
    field: 'name', 
    comparator: (value1, value2, node1, node2) => node1.data.key - node2.data.key
  }
];

这是 Plunker:Custom Sorting ag-Grid