简体   繁体   English

带有修饰键的 Ag-Grid 自定义排序

[英]Ag-Grid custom sorting with modifier key

I have a use case to cycle custom sort logic so that user could sort naturally as well as sort by absolute value if shift key is pressed.我有一个用例来循环自定义排序逻辑,以便用户可以在按下 shift 键时自然排序以及按绝对值排序。

Since custom sorting is defined in column definition there is no direct hook to grid, and unlike cell renderer - there is no way to read the context and get the state由于自定义排序是在列定义中定义的,因此没有直接挂钩到网格,并且与单元格渲染器不同 - 无法读取上下文并获取 state

In Ag-grid we can custom sort via compartor在 Ag-grid 中,我们可以通过比较器自定义排序

const gridOptions = {
    autoGroupColumnDef: {
        field: 'athlete',
        comparator: function(valueA, valueB, nodeA, nodeB, isDescending) {
            //How do i detect if shift key is pressed at this point??
            return (valueA == valueB) ? 0 : (valueA > valueB) ? 1 : -1;
        },
    },
}

How can i hook up and detect if shift key is pressed at the point of sorting?我如何连接并检测在排序时是否按下了 shift 键?

Apparently nodeA optionwrapper.gridOptions.context allows to get the grid level context directly显然 nodeA optionwrapper.gridOptions.context 允许直接获取网格级别上下文

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

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