# DataGridSelectionChangeEvent (@salmonui/data-grid)

> The DataGridSelectionChangeEvent interface of @salmonui/data-grid: 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.

Canonical: https://salmonui.dev/docs/reference/data-grid/DataGridSelectionChangeEvent

```ts
import type { DataGridSelectionChangeEvent } from '@salmonui/data-grid';
```

Entry index: https://salmonui.dev/docs/reference/data-grid (Markdown with every symbol of the entry: https://salmonui.dev/docs/reference/data-grid.md).

## Reference

Kind: interface

```ts
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.

Members (19):

| Name | Signature | Flags | Description |
| --- | --- | --- | --- |
| `rowIds` | `readonly rowIds: readonly RowId[];` |  | Selected row ids after the change. |
| `added` | `readonly added: readonly RowId[];` |  | Rows that become selected / deselected. |
| `removed` | `readonly removed: readonly RowId[];` |  |  |
| `rows` | `rows(): readonly Row[];` |  | Selected rows (raw references), in `rowIds` order. |
| `cells` | `readonly cells: readonly DataGridCellKey[];` |  | Selected cells after the change: the anchor and focus cell of each range, like `api.getSelectedCells()`. |
| `addedCells` | `readonly addedCells: readonly DataGridCellKey[];` |  | Cells that become selected / deselected (every cell of the changed ranges; O(cells in the ranges)). |
| `removedCells` | `readonly removedCells: readonly DataGridCellKey[];` |  |  |
| `columns` | `readonly columns: readonly string[];` |  | Selected column fields after the change. |
| `addedColumns` | `readonly addedColumns: readonly string[];` |  | Columns that become selected / deselected. |
| `removedColumns` | `readonly removedColumns: readonly string[];` |  |  |
| `scope` | `readonly scope: 'explicit' \| 'allFiltered';` |  | `allFiltered` after a select-all across pages: `excludedRowIds` lists the exceptions. |
| `excludedRowIds` | `readonly excludedRowIds: readonly RowId[];` |  |  |
| `ctrlKey` | `readonly ctrlKey: boolean;` |  |  |
| `shiftKey` | `readonly shiftKey: boolean;` |  |  |
| `target` | `readonly target: 'row' \| 'cell' \| 'column' \| 'checkbox' \| null;` |  |  |
| `type` | `type: string;` | inherited | `'sortChange'`, `'beforeSortChange'`, ... |
| `source` | `source: DataGridEventSource;` | inherited |  |
| `defaultPrevented` | `defaultPrevented: boolean;` | inherited | True after `preventDefault()` (before-events and click events). |
| `preventDefault` | `preventDefault: () => void;` | inherited | Before-events and click events: cancels the action (or the built-in behavior). |
