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

Full TypeScript signature sourced from the composable file.

typescript

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.

Consumed interfaces

IDataTableProvideSelection
IDataTableSelectableItem
IDataTableSelectProps

API

Return values

Properties and methods exposed by the composable return object.

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

Examples

Ready-to-paste usage snippets.

Row checkbox cell using useSelection

vue

Select-all header checkbox

vue