SelectionMethods
Selection methods returned from useGridSelection.
Uses the injected grid element from TbwGrid’s provide/inject. Methods work immediately when grid is available.
Properties
Section titled “Properties”| Property | Type | Description |
|---|---|---|
selectAll | () => void | Select all rows (row mode) or all cells (range mode). |
clearSelection | () => void | Clear all selection. |
getSelection | () => SelectionResult | unknown | Get the current selection state. Use this to derive selected rows, indices, etc. |
isCellSelected | (row: number, col: number) => boolean | Check if a specific cell is selected. |
setRanges | (ranges: CellRange[]) => void | Set 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. |
selection | Ref<SelectionResult | unknown> | Reactive selection state. Updates automatically whenever the selection changes. null when no SelectionPlugin is active or nothing is selected. v2.5.0+ |
selectedRowIndices | Ref<number[]> | Reactive selected row indices (sorted ascending). Empty in cell/range modes or when nothing is selected. v2.5.0+ |
selectedRows | Ref<TRow[]> | Reactive selected row objects. Works in all selection modes. v2.5.0+ |
isReady | Ref<boolean> | Whether the grid has finished its first render and the selection plugin has been discovered. v2.5.0+ |
Property Details
Section titled “Property Details”getSelectedRows
Section titled “getSelectedRows”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.
selectedRowIndices
Section titled “selectedRowIndices”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.