WarUI

Sort nodes with multi-key and null ordering

GRID-A05-F02P0baselineShippedexperimental

Sort orders by several keys in priority order with explicit null placement, so every backend produces the same row order.

Live example

Expected behavior

Each Shift+click appends a sort node and the header shows a priority badge. Changing the default nulls order rewrites the nulls value on existing nodes. Exceeding the maximum drops the oldest key and shows a notice.

Source

const api = createGrid({
  rows, columns,
  maxSortKeys: 3,
  defaultNullsOrder: 'last',
});
api.setSort([
  { columnId: 'status', direction: 'asc' },
  { columnId: 'amount', direction: 'desc', nulls: 'last' },
]);
api.on('sortChange', ({ sort }) => console.log(sort)); // nulls is always explicit
api.setQueryAst({ ...api.getQueryAst(), sort: tooManyKeys }); // throws GridConfigError

API reference

GRID-A05-F02 API
KindNameTypeDescription
TypeSortNode—A sort key with columnId, direction and explicit nulls.
OptionmaxSortKeys—Maximum number of sort keys. Defaults to 3.
OptiondefaultNullsOrder—first, last or backend-default for nodes without nulls.
MethodsetSort—Applies an ordered list of sort nodes.
EventsortChange—Fires once per change with the explicit sort nodes.

Acceptance criteria

  • Sort nodes preserve user-chosen priority order (met)
  • The 'nulls' property is always explicit in the serialized AST, never omitted (met)
  • A sort list longer than maxSortKeys fails validation when supplied via setQueryAst (met)
  • Sorting the same field twice in one list is rejected as a duplicate (met)