UNPKG

863 BPlain TextView Raw
1import {RowNode} from "./entities/rowNode";
2import {Utils as _} from './utils';
3
4export function defaultGroupComparator(valueA: any, valueB: any, nodeA: RowNode, nodeB: RowNode, accentedCompare: boolean = false): number {
5 console.warn('ag-Grid: Since ag-grid 11.0.0 defaultGroupComparator is not necessary. You can remove this from your colDef');
6 let nodeAIsGroup = _.exists(nodeA) && nodeA.group;
7 let nodeBIsGroup = _.exists(nodeB) && nodeB.group;
8
9 let bothAreGroups = nodeAIsGroup && nodeBIsGroup;
10 let bothAreNormal = !nodeAIsGroup && !nodeBIsGroup;
11
12 if (bothAreGroups) {
13 return _.defaultComparator(nodeA.key, nodeB.key, accentedCompare);
14 } else if (bothAreNormal) {
15 return _.defaultComparator(valueA, valueB, accentedCompare);
16 } else if (nodeAIsGroup) {
17 return 1;
18 } else {
19 return -1;
20 }
21}