useSort
DataTable
stable
Inject accessor for the sort context provided by provideSort inside OrigamDataTable. Returns the reactive sortBy array and the toggleSort / isSorted helpers. Used by header cells to read and update the active sort columns. The companion useSortedItems applies the sort order to a reactive item list.
API
Signature
Signature TypeScript complète extraite du fichier du composable.
useSort throws when called outside a DataTable context (no inject match). It must be used inside a component tree that has provideSort() called by the parent table.
Interfaces consommées
IDataTableProvideSort
IDataTableSortItem
IDataTableSortProps
IInternalDataTableHeader
API
Valeurs de retour
Propriétés et méthodes exposées par l'objet retourné par le composable.
- sortBy
- Reactive array of active sort descriptors, each with a key (column key) and an order (asc | desc). Driven by useVModel against the host table props.
- toggleSort
- Cycle the sort state for a column: none → asc → desc → none (or asc when mustSort=true). Respects multiSort — when false, replaces the entire sortBy array with a single entry.
- isSorted
- Returns true when the column has an active sort entry in sortBy. Used by header cells to show the sort icon.
Usage
Exemples
Extraits de code prêts à coller.
Sortable data table header cell
Sorted items computed ref