View as Markdown

API reference: @salmonui/data-grid

DataGridSelectionChangeEventinterface

import type { DataGridSelectionChangeEvent } from '@salmonui/data-grid';
interface DataGridSelectionChangeEvent<Row> extends DataGridEvent {
    readonly rowIds: readonly RowId[];
    readonly added: readonly RowId[];
    readonly removed: readonly RowId[];
    rows(): readonly Row[];
    readonly cells: readonly DataGridCellKey[];
    readonly addedCells: readonly DataGridCellKey[];
    readonly removedCells: readonly DataGridCellKey[];
    readonly columns: readonly string[];
    readonly addedColumns: readonly string[];
    readonly removedColumns: readonly string[];
    readonly scope: 'explicit' | 'allFiltered';
    readonly excludedRowIds: readonly RowId[];
    readonly ctrlKey: boolean;
    readonly shiftKey: boolean;
    readonly target: 'row' | 'cell' | 'column' | 'checkbox' | null;
}

onBeforeSelectionChange / onSelectionChange: one event per selection command, for row, cell and column selection, selecting and deselecting alike. Every selection field is the selection after the change (proposed in the before-event, applied in the after-event); target names the part the command selects. Large fields are computed on first read; read them synchronously. Built only while a handler is bound.

DataGridSelectionChangeEvent members (19, 4 inherited)
NameSignatureDescription
rowIdsreadonly rowIds: readonly RowId[];

Selected row ids after the change.

addedreadonly added: readonly RowId[];

Rows that become selected / deselected.

removedreadonly removed: readonly RowId[];
rowsrows(): readonly Row[];

Selected rows (raw references), in rowIds order.

cellsreadonly cells: readonly DataGridCellKey[];

Selected cells after the change: the anchor and focus cell of each range, like api.getSelectedCells().

addedCellsreadonly addedCells: readonly DataGridCellKey[];

Cells that become selected / deselected (every cell of the changed ranges; O(cells in the ranges)).

removedCellsreadonly removedCells: readonly DataGridCellKey[];
columnsreadonly columns: readonly string[];

Selected column fields after the change.

addedColumnsreadonly addedColumns: readonly string[];

Columns that become selected / deselected.

removedColumnsreadonly removedColumns: readonly string[];
scopereadonly scope: 'explicit' | 'allFiltered';

allFiltered after a select-all across pages: excludedRowIds lists the exceptions.

excludedRowIdsreadonly excludedRowIds: readonly RowId[];
ctrlKeyreadonly ctrlKey: boolean;
shiftKeyreadonly shiftKey: boolean;
targetreadonly target: 'row' | 'cell' | 'column' | 'checkbox' | null;
typeinheritedtype: string;

'sortChange', 'beforeSortChange', ...

sourceinheritedsource: DataGridEventSource;
defaultPreventedinheriteddefaultPrevented: boolean;

True after preventDefault() (before-events and click events).

preventDefaultinheritedpreventDefault: () => void;

Before-events and click events: cancels the action (or the built-in behavior).