useSort
The useSort plugin adds sorting functionality to your DataTable.
In order to mark a column as sortable, add sortable: true
to any of the columns specified in your columns
array. Then initialize the useSort()
hook in your component and pass it to the DataTable as part of the plugins
array.
Result
Loading...
Live Editor
Statefully Managed
Result
Loading...
Live Editor
Plugin
PluginProperties
Type: Object
Properties
sortId
String? Initial sorted column id (matches column key).sortDirection
String? The initial sorted column direction. One of 'desc' or 'asc'.onSort
Function? A callback that will be called whenever a sort action occurs.
useSort
Create a plugin hook that enables DataTable sorting for columns with sortable: true
by adding a sorting component to the table bar.
Parameters
props
PluginProperties (optional, default{}
)
Returns Plugin
onSort
A callback that will be called whenever a filter is applied.
Parameters
Event
ObjectonSortPayload
Object An object containing the sortId and next sortDirection.