View as Markdown

API reference: @salmonui/data-grid/engine

SelectionApiinterface

import type { SelectionApi } from '@salmonui/data-grid/engine';

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

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;
}
SelectionApi members (15)
NameSignatureDescription
selectRowsselectRows(rowIds: RowId | readonly RowId[], options?: { mode?: RowMode; }): CommandResult;

Replaces by default; add keeps the current selection.

selectRowRangeselectRowRange(fromId: RowId, toId: RowId, options?: { mode?: 'replace' | 'add'; }): CommandResult;

Selects the rows between two ids (visible order).

toggleRowSelectiontoggleRowSelection(rowId: RowId): CommandResult;
selectAllselectAll(): CommandResult;

Ctrl+A: every row of the current page (all rows without paging).

selectAllFilteredselectAllFiltered(): CommandResult;

Every row matching the query on every page, O(1) (scope allFiltered).

clearSelectionclearSelection(parts?: { rows?: boolean; cells?: boolean; columns?: boolean; }): CommandResult;

Clears every selection, or only the rows, cells or columns parts.

selectCellsselectCells(cells: readonly CellKey[], options?: { mode?: 'replace' | 'add' | 'toggle'; }): CommandResult;
selectCellRangeselectCellRange(anchor: CellKey, focus: CellKey, options?: { mode?: 'replace' | 'add'; }): CommandResult;
selectColumnsselectColumns(columnIds: ColumnId | readonly ColumnId[], options?: { mode?: 'replace' | 'add' | 'toggle'; }): CommandResult;
isRowSelectedisRowSelected(rowId: RowId): boolean;
getSelectedRowIdsgetSelectedRowIds(): readonly RowId[];

Selected row ids.

getSelectedRowsgetSelectedRows(): readonly Row[];

Selected raw rows, in the order of getSelectedRowIds().

getSelectiongetSelection(): SerializedSelection | undefined;

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

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