useSelection
DataTable
stable
Inject accessor for the row-selection context provided by provideSelection inside OrigamDataTable. Returns the reactive selected Set and the select / toggleSelect / selectAll helpers plus status flags (someSelected, allSelected, showSelectAll). Used by checkbox columns and the header select-all control.
API
Signature
Signature TypeScript complète extraite du fichier du composable.
useSelection throws when called outside a DataTable context (no inject match for ORIGAM_DATA_TABLE_SELECT_KEY). It must be used inside a component tree where provideSelection() was called by the parent table.
Interfaces consommées
IDataTableProvideSelection
IDataTableSelectableItem
IDataTableSelectProps
API
Valeurs de retour
Propriétés et méthodes exposées par l'objet retourné par le composable.
- isSelected
- Returns true when every item in the argument list is in the selected Set.
- isSomeSelected
- Returns true when at least one item in the argument list is selected.
- select
- Set the selection state of the given items to value. Delegates to the active selectStrategy (single, page, or all).
- toggleSelect
- Toggle the selection state of a single item.
- selectAll
- Select or deselect all eligible items according to the active strategy. Strategy page selects only the current page; strategy all selects across all pages.
- someSelected
- True when the selected Set is non-empty. Used to render the indeterminate state on the select-all checkbox.
- allSelected
- True when all eligible items (non-disabled) are selected according to the active strategy.
- showSelectAll
- Whether the select-all checkbox should be visible. Always false for the single select strategy.
Usage
Exemples
Extraits de code prêts à coller.
Row checkbox cell using useSelection
Select-all header checkbox