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

> The SelectionApi interface of @salmonui/data-grid/engine.

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

```ts
import type { SelectionApi } 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 SelectionApi<Row> {
    selectRows(rowIds: RowId | readonly RowId[], options?: {
        mode?: RowMode;
    }): CommandResult;
    selectRowRange(fromId: RowId, toId: RowId, options?: {
        mode?: 'replace' | 'add';
    }): CommandResult;
    toggleRowSelection(rowId: RowId): CommandResult;
    selectAll(): CommandResult;
    selectAllFiltered(): CommandResult;
    clearSelection(parts?: {
        rows?: boolean;
        cells?: boolean;
        columns?: boolean;
    }): CommandResult;
    selectCells(cells: readonly CellKey[], options?: {
        mode?: 'replace' | 'add' | 'toggle';
    }): CommandResult;
    selectCellRange(anchor: CellKey, focus: CellKey, options?: {
        mode?: 'replace' | 'add';
    }): CommandResult;
    selectColumns(columnIds: ColumnId | readonly ColumnId[], options?: {
        mode?: 'replace' | 'add' | 'toggle';
    }): CommandResult;
    isRowSelected(rowId: RowId): boolean;
    getSelectedRowIds(): readonly RowId[];
    getSelectedRows(): readonly Row[];
    getSelection(): SerializedSelection | undefined;
    setSelection(selection: SerializedSelection): CommandResult;
    getSelectionSummary(): SelectionSummary | undefined;
}
```

Members (15):

| Name | Signature | Flags | Description |
| --- | --- | --- | --- |
| `selectRows` | `selectRows(rowIds: RowId \| readonly RowId[], options?: {     mode?: RowMode; }): CommandResult;` |  | Replaces by default; `add` keeps the current selection. |
| `selectRowRange` | `selectRowRange(fromId: RowId, toId: RowId, options?: {     mode?: 'replace' \| 'add'; }): CommandResult;` |  | Selects the rows between two ids (visible order). |
| `toggleRowSelection` | `toggleRowSelection(rowId: RowId): CommandResult;` |  |  |
| `selectAll` | `selectAll(): CommandResult;` |  | Ctrl+A: every row of the current page (all rows without paging). |
| `selectAllFiltered` | `selectAllFiltered(): CommandResult;` |  | Every row matching the query on every page, O(1) (scope `allFiltered`). |
| `clearSelection` | `clearSelection(parts?: {     rows?: boolean;     cells?: boolean;     columns?: boolean; }): CommandResult;` |  | Clears every selection, or only the `rows`, `cells` or `columns` parts. |
| `selectCells` | `selectCells(cells: readonly CellKey[], options?: {     mode?: 'replace' \| 'add' \| 'toggle'; }): CommandResult;` |  |  |
| `selectCellRange` | `selectCellRange(anchor: CellKey, focus: CellKey, options?: {     mode?: 'replace' \| 'add'; }): CommandResult;` |  |  |
| `selectColumns` | `selectColumns(columnIds: ColumnId \| readonly ColumnId[], options?: {     mode?: 'replace' \| 'add' \| 'toggle'; }): CommandResult;` |  |  |
| `isRowSelected` | `isRowSelected(rowId: RowId): boolean;` |  |  |
| `getSelectedRowIds` | `getSelectedRowIds(): readonly RowId[];` |  | Selected row ids. |
| `getSelectedRows` | `getSelectedRows(): readonly Row[];` |  | Selected raw rows, in the order of `getSelectedRowIds()`. |
| `getSelection` | `getSelection(): SerializedSelection \| undefined;` |  | Serializable selection (scope, ids or excluded ids, cell ranges, columns). |
| `setSelection` | `setSelection(selection: SerializedSelection): CommandResult;` |  |  |
| `getSelectionSummary` | `getSelectionSummary(): SelectionSummary \| undefined;` |  |  |
