Custom Comparator per Column
Developers can supply a comparator function for a column. The function receives both values, both row nodes and the sort direction, which allows domain-specific ordering. A typical example is ordering a severity column as Critical > High > Medium > Low instead of alphabetically. The comparator is always written for ascending order; the grid inverts the result for descending order.
Planned. This page shows the specification from issue #186. The live example, source for every framework and the API reference replace it when the feature ships.
Live example
An incident grid with a Severity column using a rank-map comparator.
Expected behavior
Ascending order shows Low, Medium, High, Critical. Reordering the chips immediately re-sorts the grid. Turning the comparator off shows alphabetical order: Critical, High, Low, Medium.
Planned API surface
columns[].comparatorComparatorParams { valueA, valueB, nodeA, nodeB, isDescending }Acceptance criteria
- The comparator is called with ascending semantics in both directions, and the grid applies the inversion (pending)
- A return value < 0, 0 or > 0 is interpreted in the standard way (pending)
- A comparator that throws is caught; sorting falls back to the default comparator and an error event is reported (pending)
- Null, empty and NaN placement rules (F11) apply before the custom comparator unless comparatorHandlesEmpty=true (pending)
- Changing the comparator reference re-sorts the grid if the column is currently sorted (pending)