Skip to content

Data Grid

alikit:data_grid is an interactive, virtualized, non-spanned grid over Alicorn’s compound table roles. The application owns columns, rows, comparators, filters, and the accepted selection; the grid owns ephemeral roving cell focus, reveal, selected/current publication, sort-header proposals, and one cell activation proposal. Shared column tracks, headers, and cell scaffolding come from alikit:table_core.

Native data grid window with a filter field and an interactive document grid with selected row and cell
Native SDL_GPU capture of examples/data_grid at Alicorn 47c9d4a. The application filters and sorts its own dataset; the grid owns roving focus, reveal, and proposals.
The capture is the real native grid; the interactive contract is documented and tested in the package.
LayerResponsibility
AlicornGrid tracks, virtual list, semantic collections, table roles, focus, pointer hit testing, virtual item projection.
table_coreShared Column/Cell/Row/Alignment/Sort_State shapes, tracks, header parts, cell semantics, surface fallback.
data_gridInteractive body composition, roving cell coordinates, row reveal, sort-header proposals, one activation proposal, theme contract.
ApplicationColumns, rows, stable keys, comparators, filters, accepted selection, dispatch, editing policy.

The component stores only ephemeral focus and proposal state. It publishes Selected from the application’s Selection but never mutates it.

Files: data_grid/data_grid.odin, data_grid/data_grid_test.odin, examples/data_grid/main.odin, examples/data_grid/theme.json.

import data_grid "alikit:data_grid"
event := data_grid.data_grid(
ctx,
&app.view,
app.columns[:],
app.projection[:app.visible_count],
app.selection,
data_grid.Options{accessible_label="Documents", row_header=true,
max_visible_rows=10, row_height=30},
key=alicorn.key_string("documents"),
instance_id=1,
recipe=app.recipe,
)
switch event.kind {
case .Activated:
app.selection = data_grid.Selection{row_key=event.row_key, column_key=event.column_key}
case .Sort_Proposed:
app.toggle_sort(event.column_key)
}

Call data_grid.request_focus(&state) to focus the single Tab stop.

PartIdentityWhat can be omitted or replaced
Gridgrid_semantic_id(instance_id)Always present. Publishes Table; grid roles are pending in Alicorn.
Header rowheader_row_semantic_id(instance_id)Omit with Options.hide_header; shared header parts.
Header cellheader_cell_semantic_id(instance_id, column_key)Table_Column_Header; Column.sortable adds Press and Sort_Proposed.
Body rowrow_semantic_id(instance_id, row_key)Nested Table_Row.
Body cellcell_semantic_id(instance_id, row_key, column_key)Table_Cell / Table_Row_Header; selected/current states.

Column, Cell, Row, Alignment, and Sort_State are aliases of alikit:table_core shapes. Column.sort is presentation input only: the application changes its projection and accepted direction.

Recipe declares four optional namespaced roles: header surface, row surface, selected row surface, and selected cell surface. Style carries corner radius, focus outline width, and selected-cell outline width. Options carries row/header heights, visible rows, gaps, padding, and text sizes.

Selection is shown by row fill plus a selected-cell surface and accent outline, not color alone. Roving focus and reveal are immediate; there is no animation.

  • Tab reaches the grid once. Body cells are not separate Tab stops.
  • Up/Down move the focused row, skipping disabled rows and preserving the column. Page Up/Down move by max_visible_rows and clamp to the first/last enabled row. Left/Right move the cell coordinate; Home/End target the first/last column.
  • Return/Space propose the active cell; pointer and semantic activation use the same path.
  • Disabled rows publish Disabled, skip navigation, and do not activate.
  • The collection publishes Table with accessible name, logical row count, selected row, and current row. Header cells publish sort direction and a Press action when sortable.
  • Not claimed: cell spans, editing, multi-select, column resizing/reordering, built-in sorting/filtering, or a composite grid role.

Alicorn’s pinned role set has Table, Table_Row, Table_Cell, Table_Column_Header, and Table_Row_Header, but no Grid/Grid_Cell. v1 uses the table roles and keeps the grid-role question as an Alicorn-side proposal.

data_grid/data_grid_test.odin covers:

  • identities, shared column tracks, and theme diagnostics;
  • Table logical count, nested row/cell collections, row-header cells, selected/current coordinates;
  • Up skipping a disabled row, Down, Home/End columns, Return activation, and pointer parity;
  • sortable header semantics, direction description, Press action, and Sort_Proposed;
  • 200-row virtualization with virtual semantic rows and Page Down reveal;
  • the native example smoke path.
Terminal window
odin test data_grid -define:ODIN_TEST_THREADS=1 -collection:alicorn=<alicorn> -collection:alikit=.
./out/data_grid_example.exe --smoke

There is no testui data-grid pattern at the pinned revision; explicit drive assertions are used.

DeclarationNotes
Alignment, Sort_State, Column, Cell, RowAliases of alikit:table_core shapes.
SelectionSelected row_key and column_key.
OptionsAccessible/empty labels, header visibility, row header, geometry, text sizes.
Recipe / StyleOptional namespaced surface roles and visual geometry.
StateActive row/column coordinate, focus/reveal requests, pending proposal.
Event / Event_KindActivated or Sort_Proposed.
data_gridDescribe the grid and return one proposal.
request_focusFocus the grid’s Tab stop after layout.
recipe_default, style_defaultCore-role defaults.
theme_contract_default, theme_contract_check, theme_contract_satisfied, theme_contract_missing_requiredSetup-time validation.
grid_semantic_id, header_row_semantic_id, header_cell_semantic_id, row_semantic_id, cell_semantic_idStable semantic identities.
  • Headless tests do not prove a physical screen-reader grid session or pixels.
  • Non-spanned only; columns cap at 64. Virtual rows publish cells only when realized.
  • Sorting and filtering are application callbacks over the projection.
Pin: built against Alicorn 47c9d4a7cd1f637876190fec899daeeac00a30ae. See Compatibility and pinning.