LyteNyte Grid logo for light mode. Links back to the documentation home page.
Pivoting

Pivot Sorting

Pivot columns support sorting. Sort rows in ascending or descending order based on any pivot column.

Note

This guide assumes familiarity with client sorting. Pivot sorting works the same way, but applies sorts to the pivot model. See the Client Row Sorting guide for details.

Sorting Pivots

To sort pivot columns, set the sort property on the pivot model. In the demo below, click a column header to sort by that pivot column. The demo uses a measure that sums Profit.

Pivot Sorting

Fork code on stack blitzFork code on code sandbox

The demo applies the sort configuration to the pivot model state. As a result, rows are sorted based on the generated pivot columns. If the pivot columns change, the sort is removed because the sorted field no longer exists.

LyteNyte Grid generates IDs for pivot columns based on pivot data. For example, in the demo above, the ID of the 25-34 column is "25-34-->profit". The first segment represents the cell value from the Age Group column, and the second segment represents the ID of the applied measure, in this case Profit. Use this generated sort ID when defining a sort function for pivoted rows.

If you need predictable column IDs, use the pivotColumnProcessor property on the client data source to modify column IDs before the pivot columns are returned.

Next Steps