Advanced Table

Sorting

Enable Sorting


the enableSorting prop is a boolean prop set to false by default. If true, the table will add sort logic linked to the sort button in the header. Clicking the sort button will toggle sort between ascending and descending. Currently this sort functionality is only available on the first column.

sortIcon

An optional prop, sortIcon allows you to customize your icon sets by passing it an array of any comma-separated pair of icon values. The first icon value will replace the kit's default icon when sort direction is desc, and the second value will replace the default icon when sort direction is asc. sortIcon also allows you to pass it a single icon as a string, in which case the icon will not toggle with the sort state. Default for this prop is ["arrow-up-wide-short", "arrow-down-short-wide"]. All strings must be valid FA icons.

Sort Control


sortControl is an optional prop that can be used to gain greater control over the sort state of the Advanced Table. Tanstack handles sort itself, however it does provide for a way to handle the state manually if needed. Usecases for this include needing to store the sort state so it persists on page reload, set an initial sort state, etc.

The sort state must be an object with a single key/value pair, with the key being "desc" and the value being a boolean. The default for sort direction is desc: true.

Enable Sort By Column


Sorting can now be enabled on any of the columns. To do this, add enableSort:true to the columnDefinition of the column you want sorting enabled on. Once enabled, clicking on the header will toggle sort between ascending and descending.

The optional enableSortingRemoval prop can also be used in conjunction with sorting functionality. This prop is set to 'false' by default but if set to 'true' sorting order will circle like: 'none' -> 'desc' -> 'asc' -> 'none' -> ...
It is recommended that enableSortingRemoval be set to 'true' when sort is enabled on mutiple columns so that sorting direction is always clear via the sort icon.

NOTE: For sort on the first column, continue to use the separate enableSorting prop on AdvancedTable.Header as shown here.

Enable Sort By Column (Multi-Column)


Sorting on columns can also be applied to columns when using the multi-header variant, however in this case sorting can only be set on leaf columns NOT on parent columns.

Custom Sort


The optional customSort prop can be used to add a sort button within a subrow header. The button will only appear if that subrowheader has more than one subrow nested within it. This button comes with a callback function called onCustomSortClick.

The onCustomSortClick provides as an argument an array of all the subrows nested within that level of the table.

NOTE: customSort must be used in conjunction with the subRowHeaders prop. The customSort DOES NOT handle the sort logic, this must be handled on the frontend using the callback provided.

Sort Parent Only


The sortParentOnly prop is a boolean set to false by default. When set to true, only parent (depth-0) rows are re-ordered when sorting; children and grandchildren stay grouped under their parent and keep their original order.

sortParentOnly works with every sorting mode: enableSorting on the header, per-column enableSort: true, and sortable leaf columns in the multi-header variant. Sort indicators behave as usual.

When omitted or false, sorting applies to all levels.


Available Props