View as Markdown

API reference: @salmonui/data-grid

DataGridSelectionApiinterface

import type { DataGridSelectionApi } from '@salmonui/data-grid';
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).

DataGridSelectionApi members (15)
NameSignatureDescription
selectRowsselectRows(rowIds: RowId | readonly RowId[], options?: { mode?: 'replace' | 'add' | 'remove' | 'toggle'; }): DataGridActionResult;
selectRowRangeselectRowRange(fromRowId: RowId, toRowId: RowId, options?: { mode?: 'replace' | 'add'; }): DataGridActionResult;
selectAllselectAll(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).

clearSelectionclearSelection(parts?: { rows?: boolean; cells?: boolean; columns?: boolean; }): DataGridActionResult;
selectCellsselectCells(cells: readonly DataGridCellKey[], options?: { mode?: 'replace' | 'add' | 'toggle'; }): DataGridActionResult;
selectCellRangeselectCellRange(anchor: DataGridCellKey, focus: DataGridCellKey, options?: { mode?: 'replace' | 'add'; }): DataGridActionResult;
selectColumnsselectColumns(fields: string | readonly string[], options?: { mode?: 'replace' | 'add' | 'toggle'; }): DataGridActionResult;
isRowSelectedisRowSelected(rowId: RowId): boolean;
getSelectedRowIdsgetSelectedRowIds(): readonly RowId[];
getSelectedRowsgetSelectedRows(): readonly Row[];

Raw rows, in the order of getSelectedRowIds().

getSelectedCellsgetSelectedCells(): readonly DataGridCellKey[];
getSelectedColumnsgetSelectedColumns(): readonly string[];
getSelectiongetSelection(): SerializedSelection | undefined;

Serializable selection (scope, ids or excluded ids, cell ranges, columns).

setSelectionsetSelection(selection: SerializedSelection): DataGridActionResult;
getSelectionSummarygetSelectionSummary(): SelectionSummary | undefined;