Home > Software design >  How to sort by the row group count in ag grid?
How to sort by the row group count in ag grid?

Time:06-13

I'm using rows group in ag-grid,

Is it possible to sort the group column by the row count?

As follow:

enter image description here

CodePudding user response:

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

  • Related