LyteNyte Grid logo for light mode. Links back to the documentation home page.
Columns

Marker Column

The marker column is an auxiliary column created and managed by LyteNyte Grid. It is always pinned to the start of the viewport.

Use the marker column for information that does not come from the row data or for interactive actions that do not fit cleanly into other columns. Common use cases include:

  • Displaying the current row index.
  • Rendering a checkbox for row selection.

Enabling Marker Column

To enable the marker column, add a columnMarker definition to the grid and set its on property to true.

const marker: Grid.ColumnMarker<GridSpec> = {
on: true,
// Other marker column properties
};

The demo below shows the marker column displaying row indices. The displayed index starts at 1, while actual row indices in LyteNyte Grid start at 0.

Row Index Marker Column

//!
Fork code on stack blitzFork code on code sandbox

The marker column differs from standard columns and has important restrictions:

  • It is always pinned to the start of the viewport.
  • It cannot be moved or reordered.
  • It is not part of the columns state but does affect column display order. When enabled, the marker column will always appear first, and display index 0 always refers to the marker column.

Selection Marker Column

A common use case for the marker column is row selection. The marker column can render a checkbox for each row. Because this is so common, LyteNyte Grid provides the api.rowHandleSelect method to simplify selection logic, including shift-select behavior.

Marker Column Selection

Fork code on stack blitzFork code on code sandbox

The demo uses api.rowHandleSelect to manage checkbox interactions:

<GridCheckbox
checked={selected}
onClick={(ev) => {
ev.stopPropagation();
api.rowHandleSelect({ shiftKey: ev.shiftKey, target: ev.target });
}}
onKeyDown={(ev) => {
if (ev.key === "Enter" || ev.key === " ")
api.rowHandleSelect({ shiftKey: ev.shiftKey, target: ev.target });
}}
/>

Next Steps

  • Column Resizing: Change column widths programmatically or via user interaction.
  • Column Moving: Reorder columns programmatically or through drag-and-drop.
  • Column Groups: Create a column header hierarchy and associate columns with column groups.
  • Column Field: Control how a column retrieves its value for each cell.