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

Rows Overview

Learn how the LyteNyte grid creates, renders, and manages rows. LyteNyte Grid has three types of rows, group rows, aggregated rows, and leaf rows. These rows define the grid's main content.

Row Node Interface

LyteNyte Grid represents rows using the RowNode interface. This interface is a union of three types:

  • RowGroup: A row that contains child rows and establishes a hierarchical relationship.
  • RowAggregated: A row that contains aggregate data but is not a group node that can be expanded.
  • RowLeaf: A row with no child rows.

You can distinguish between row node types by checking the kind property. For example:

const row: RowNode = { ... };
const isLeaf = row.kind === "leaf";
const isGroup = row.kind === "branch";
const isAggregated = row.kind === "aggregated";

LyteNyte Grid also provides convenience methods for identifying row node types. When using TypeScript, these methods will narrow the type of the RowNode union:

const isLeaf = api.rowIsLeaf(row);
const isGroup = api.rowIsGroup(row);
const isAggregated = api.rowIsAggregated(row);

Row Indices

The RowNode interface intentionally omits a row index because a row node does not always correspond to a rendered row. The grid’s data source creates row nodes, and some data sources, such as the server data source, can return rows that are not yet visible. These rows do not have a defined row index.

Although RowNode does not store a row index, LyteNyte Grid exposes the row index when it does exist. The grid passes the rowIndex value to components and callbacks that operate on rendered rows.

Cell renderers, for example, receive a rowIndex prop, as shown in the row index demo below:

Row Indexing

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

The marker column displays the row index for each rendered row. The following cell renderer adds 1 to the index because LyteNyte Grid uses zero-based indexing:

const cellRenderer = (p) => {
return <div>{p.rowIndex + 1}</div>;
};

Next Steps

  • Row Height: Change row height, support variable-height rows, and configure fill-height rows.
  • Row Pinning: Freeze rows at the top or bottom of the viewport.
  • Row Selection: Select single or multiple rows.
  • Row Master Detail: Render expandable row detail content, including nested grids.