Skip to content

Grid interaction and selection

View as Markdown

The interaction preset decides what arrow keys, Enter, double-click, and selection mean before a custom cell handles them. Presets configure interaction; the application still renders any side panel or master-detail layout.

PresetPrimary use
CELL_EDITING_GRIDSpreadsheet-style entry
CELL_GRID_WITH_INDEPENDENT_ROW_SELECTIONCell editing plus bulk row actions
CELL_PRIMARY_WITH_SIDE_PANEL_ROWDetail follows the cell cursor
CELL_PRIMARY_WITH_SELECTED_SIDE_PANEL_ROWDetail stays on a selected row
ROW_PRIMARY_MASTER_DETAILRow navigation and hierarchy
ROW_PRIMARY_MASTER_DETAIL_WITH_ACTIVATIONRow navigation plus Enter or double-click action
ROW_MULTISELECT_LISTCommand-oriented bulk work

Cell selection owns focus, ranges, copy, and editing. Row selection identifies records for a panel or bulk operation. The active row identifies one current record. These states may point at the same row, but they are not synonyms.

React code reads runtime-backed state through hooks:

import { useActiveRow, useSelectedRowIds, type GridPath } from "@sapporta/grid";
function RowContext({ path }: { path: GridPath }) {
const active = useActiveRow(path);
const selected = useSelectedRowIds(path);
return (
<span>{active ? `${selected.length} selected` : "No active row"}</span>
);
}

Use the active row for a detail region that follows navigation. Use a rowActivated event for a repeatable command: pressing Enter on the same row twice should run the command twice even though active-row state did not change.

Interaction state does not change persistence or authorization. A selected ID, active row, hidden column, or fixed client filter grants no server authority.