简体   繁体   English

如何按 ag 网格中的行组计数排序?

[英]How to sort by the row group count in ag grid?

I'm using rows group in ag-grid,我在 ag-grid 中使用行组,

Is it possible to sort the group column by the row count?是否可以按行数对组列进行排序?

As follow:如下:

在此处输入图像描述

You need to define custom sorting:您需要定义自定义排序:

const gridOptions = {
    columnDefs: [
        {
            field: 'age',
            // simple number comparator
            comparator: (valueA, valueB, nodeA, nodeB, isInverted) => valueA - valueB
        },
        {
            field: 'name',
            // simple string comparator
            comparator: (valueA, valueB, nodeA, nodeB, isInverted) => {
                if (valueA == valueB) return 0;
                return (valueA > valueB) ? 1 : -1;
            }
        }
    ],

    // other grid options ...
}

https://www.ag-grid.com/javascript-data-grid/row-sorting/#custom-sorting https://www.ag-grid.com/javascript-data-grid/row-sorting/#custom-sorting

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

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