Selection

The selection primitives underneath selectable.

Last updated August 3, 2026

These transforms are what a click, a Ctrl-click, and a Shift-click each reduce to — every one takes the selection it received and returns the selection after, never touching a DOM node or a row of data. @gridkitjs/react calls them from useGridSelection; a second framework binding can call them the same way.

Functions

FunctionTypeDescription
toggleSelection(selection, id, mode)SelectionStateAdds id if absent, removes it if present — a Ctrl-click, or Space on the focused member.
selectOnly(selection, id, mode)SelectionStateThe selection reduced to id alone — a plain click. Never deselects, so clicking the one selected row leaves it selected.
selectRange(selection, orderedIds, anchorId, focusId, mode)SelectionStateEvery id from anchorId to focusId inclusive, spanning orderedIds — a Shift-click. Degrades to selectOnly under "single".
selectAll(selection, orderedIds, mode)SelectionStateEvery id in orderedIds, or selection untouched under any mode but "multiple".
clearSelection(selection)SelectionStateEmpties the selection.
diffSelection(previous, next)SelectionDiffWhat one transition added and removed — the one place a select and a deselect fired for the same interaction cannot disagree.
selectCell(selection, cell, mode)CellSelectionStateMoves the cell selection to cell — a plain click. Idempotent: clicking the selected cell again leaves it selected.
toggleCellSelection(selection, cell, mode)CellSelectionStateMoves to cell, or clears when it is already there — a Ctrl-click.
isSameCell(a, b)booleanWhether two cell selections address the same row and column.

The same logic, in the React grid

selectable

Live example
IdServiceEnvironment NameEnvironment RegionStatusCost
1checkout-apiproductionus-east-1healthy1240.5
2billing-workerproductioneu-west-1degraded860.2
3search-indexstagingus-east-1healthy92.75
4notificationsproductionus-west-2down305.4
5analytics-pipelinestagingeu-west-1healthy145
  1. Interact with the grid above to see its callbacks fire.
<DataGridComponent
  columns={columns}
  dataSource={rows}
  getRowId={(row) => String(row.Id)}
  selectable={{ rows: "multiple", columns: "multiple", cells: "single" }}
/>;
Edit this page on GitHub