SelectionMethods
Selection methods returned from injectGridSelection.
Uses lazy discovery - the grid is found on first method call, not during initialization. This ensures it works with lazy-rendered tabs, conditional rendering, etc.
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 (imperative, point-in-time snapshot). For reactive selection state, use the selection signal instead. |
isCellSelected | (row: number, col: number) => boolean | Check if a specific cell is selected. |
setRanges | (ranges: CellRange[]) => void | Set selection ranges programmatically. |
selection | Signal<SelectionResult | unknown> | Reactive selection state. Updates automatically whenever the selection changes. Null when no SelectionPlugin is active or no selection has been made yet. |
selectedRowIndices | Signal<number[]> | Reactive selected row indices (sorted ascending). Updates automatically. Convenience signal for row-mode selection — returns [] in cell/range modes or when nothing is selected. |
selectedRows | Signal<TRow[]> | Reactive selected row objects. Updates automatically whenever the selection changes. Works in all selection modes (row, cell, range) — returns the actual row objects from the grid’s processed (sorted/filtered) rows. |
isReady | Signal<boolean> | Signal indicating if grid is ready. The grid is discovered lazily, so this updates when first method call succeeds. |
Property Details
Section titled “Property Details”selection
Section titled “selection”readonly selection = injectGridSelection();
// In template:// {{ selection.selection()?.ranges?.length ?? 0 }} cells selected
// In computed:readonly hasSelection = computed(() => (this.selection.selection()?.ranges?.length ?? 0) > 0);selectedRowIndices
Section titled “selectedRowIndices”Reactive selected row indices (sorted ascending). Updates automatically.
Convenience signal for row-mode selection — returns [] 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.
readonly selection = injectGridSelection();
// In template:// {{ selection.selectedRowIndices().length }} rows selectedselectedRows
Section titled “selectedRows”Reactive selected row objects. Updates automatically whenever the selection changes. Works in all selection modes (row, cell, range) — returns the actual row objects from 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.
readonly selection = injectGridSelection<Employee>();
// In template:// {{ selection.selectedRows().length }} rows selected
// In computed:readonly hasSelection = computed(() => this.selection.selectedRows().length > 0);