# DataGridSelectionApi (@salmonui/data-grid)

> The DataGridSelectionApi interface of @salmonui/data-grid: Row and cell selection methods (ids and fields).

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

```ts
import type { DataGridSelectionApi } 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 DataGridSelectionApi<Row> {
    selectRows(rowIds: RowId | readonly RowId[], options?: {
        mode?: 'replace' | 'add' | 'remove' | 'toggle';
    }): DataGridActionResult;
    selectRowRange(fromRowId: RowId, toRowId: RowId, options?: {
        mode?: 'replace' | 'add';
    }): DataGridActionResult;
    selectAll(options?: {
        scope?: 'page' | 'filtered';
    }): DataGridActionResult;
    clearSelection(parts?: {
        rows?: boolean;
        cells?: boolean;
        columns?: boolean;
    }): DataGridActionResult;
    selectCells(cells: readonly DataGridCellKey[], options?: {
        mode?: 'replace' | 'add' | 'toggle';
    }): DataGridActionResult;
    selectCellRange(anchor: DataGridCellKey, focus: DataGridCellKey, options?: {
        mode?: 'replace' | 'add';
    }): DataGridActionResult;
    selectColumns(fields: string | readonly string[], options?: {
        mode?: 'replace' | 'add' | 'toggle';
    }): DataGridActionResult;
    isRowSelected(rowId: RowId): boolean;
    getSelectedRowIds(): readonly RowId[];
    getSelectedRows(): readonly Row[];
    getSelectedCells(): readonly DataGridCellKey[];
    getSelectedColumns(): readonly string[];
    getSelection(): SerializedSelection | undefined;
    setSelection(selection: SerializedSelection): DataGridActionResult;
    getSelectionSummary(): SelectionSummary | undefined;
}
```

Row and cell selection methods (ids and fields).

Members (15):

| Name | Signature | Flags | Description |
| --- | --- | --- | --- |
| `selectRows` | `selectRows(rowIds: RowId \| readonly RowId[], options?: {     mode?: 'replace' \| 'add' \| 'remove' \| 'toggle'; }): DataGridActionResult;` |  |  |
| `selectRowRange` | `selectRowRange(fromRowId: RowId, toRowId: RowId, options?: {     mode?: 'replace' \| 'add'; }): DataGridActionResult;` |  |  |
| `selectAll` | `selectAll(options?: {     scope?: 'page' \| 'filtered'; }): DataGridActionResult;` |  | `page`: every row of the current page (all rows without paging). `filtered` (default with paging off): every row matching the query, O(1). |
| `clearSelection` | `clearSelection(parts?: {     rows?: boolean;     cells?: boolean;     columns?: boolean; }): DataGridActionResult;` |  |  |
| `selectCells` | `selectCells(cells: readonly DataGridCellKey[], options?: {     mode?: 'replace' \| 'add' \| 'toggle'; }): DataGridActionResult;` |  |  |
| `selectCellRange` | `selectCellRange(anchor: DataGridCellKey, focus: DataGridCellKey, options?: {     mode?: 'replace' \| 'add'; }): DataGridActionResult;` |  |  |
| `selectColumns` | `selectColumns(fields: string \| readonly string[], options?: {     mode?: 'replace' \| 'add' \| 'toggle'; }): DataGridActionResult;` |  |  |
| `isRowSelected` | `isRowSelected(rowId: RowId): boolean;` |  |  |
| `getSelectedRowIds` | `getSelectedRowIds(): readonly RowId[];` |  |  |
| `getSelectedRows` | `getSelectedRows(): readonly Row[];` |  | Raw rows, in the order of `getSelectedRowIds()`. |
| `getSelectedCells` | `getSelectedCells(): readonly DataGridCellKey[];` |  |  |
| `getSelectedColumns` | `getSelectedColumns(): readonly string[];` |  |  |
| `getSelection` | `getSelection(): SerializedSelection \| undefined;` |  | Serializable selection (scope, ids or excluded ids, cell ranges, columns). |
| `setSelection` | `setSelection(selection: SerializedSelection): DataGridActionResult;` |  |  |
| `getSelectionSummary` | `getSelectionSummary(): SelectionSummary \| undefined;` |  |  |
