Skip to content

SelectionMethods

Selection methods returned from useGridSelection.

Uses the injected grid element from TbwGrid’s provide/inject. Methods work immediately when grid is available.

PropertyTypeDescription
selectAll() => voidSelect all rows (row mode) or all cells (range mode).
clearSelection() => voidClear all selection.
getSelection() => SelectionResult | unknownGet the current selection state. Use this to derive selected rows, indices, etc.
isCellSelected(row: number, col: number) => booleanCheck if a specific cell is selected.
setRanges(ranges: CellRange[]) => voidSet selection ranges programmatically.
getSelectedRows() => TRow[]Get actual row objects for the current selection. Works in all selection modes (row, cell, range) — resolves indices against the grid’s processed (sorted/filtered) rows.
selectionRef<SelectionResult | unknown>Reactive selection state. Updates automatically whenever the selection changes. null when no SelectionPlugin is active or nothing is selected. v2.5.0+
selectedRowIndicesRef<number[]>Reactive selected row indices (sorted ascending). Empty in cell/range modes or when nothing is selected. v2.5.0+
selectedRowsRef<TRow[]>Reactive selected row objects. Works in all selection modes. v2.5.0+
isReadyRef<boolean>Whether the grid has finished its first render and the selection plugin has been discovered. v2.5.0+

Get actual row objects for the current selection. Works in all selection modes (row, cell, range) — resolves indices against the grid’s processed (sorted/filtered) rows.

This is the recommended way to get selected rows. Unlike manual index mapping, it correctly resolves rows even when the grid is sorted or filtered.

For reactive selected rows, use the selectedRows ref instead.


Reactive selected row indices (sorted ascending). Empty in cell/range modes or when nothing is selected.

Prefer selectedRows for getting actual row objects — it handles index-to-object resolution correctly regardless of sorting/filtering.