# SelectionPreview (@salmonui/data-grid/engine)

> The SelectionPreview interface of @salmonui/data-grid/engine: Proposed selection of a command (rows, cells and columns), computed without committing: before-events and controlled renderers. Parts the command leaves alone report the current selection with empty added / removed lists. Large fields are computed on first read; read them synchronously.

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

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

Also exported from `@salmonui/data-grid/engine/selection`.

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

## Reference

Kind: interface

```ts
interface SelectionPreview {
    readonly scope: 'explicit' | 'allFiltered';
    readonly changes: {
        readonly rows: boolean;
        readonly cells: boolean;
        readonly columns: boolean;
    };
    readonly added: readonly RowId[];
    readonly removed: readonly RowId[];
    readonly selectedRowIds: readonly RowId[];
    readonly excludedRowIds: readonly RowId[];
    readonly cellRanges: readonly CellRange[];
    readonly addedCells: readonly CellKey[];
    readonly removedCells: readonly CellKey[];
    readonly columnIds: readonly ColumnId[];
    readonly addedColumns: readonly ColumnId[];
    readonly removedColumns: readonly ColumnId[];
}
```

Proposed selection of a command (rows, cells and columns), computed without
committing: before-events and controlled renderers. Parts the command leaves
alone report the current selection with empty added / removed lists. Large
fields are computed on first read; read them synchronously.

Members (12):

| Name | Signature | Flags | Description |
| --- | --- | --- | --- |
| `scope` | `readonly scope: 'explicit' \| 'allFiltered';` |  |  |
| `changes` | `readonly changes: {     readonly rows: boolean;     readonly cells: boolean;     readonly columns: boolean; };` |  | Which parts of the selection the command changes. |
| `added` | `readonly added: readonly RowId[];` |  | Rows that become selected / deselected; computed on first read. |
| `removed` | `readonly removed: readonly RowId[];` |  |  |
| `selectedRowIds` | `readonly selectedRowIds: readonly RowId[];` |  | Selected ids after the command; materialized on first read (O(selected)). Read synchronously. |
| `excludedRowIds` | `readonly excludedRowIds: readonly RowId[];` |  | Excluded ids when the scope is `allFiltered`. |
| `cellRanges` | `readonly cellRanges: readonly CellRange[];` |  | Cell ranges after the command. |
| `addedCells` | `readonly addedCells: readonly CellKey[];` |  | Cells (data rows, visible columns) that become selected / deselected; O(cells in the old and new ranges) on first read. |
| `removedCells` | `readonly removedCells: readonly CellKey[];` |  |  |
| `columnIds` | `readonly columnIds: readonly ColumnId[];` |  | Selected column ids after the command. |
| `addedColumns` | `readonly addedColumns: readonly ColumnId[];` |  |  |
| `removedColumns` | `readonly removedColumns: readonly ColumnId[];` |  |  |
