简体   繁体   中英

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

I'm using rows group in 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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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