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

Row Group Cell

Use LyteNyte Grid's Row Group Cell component to easily expand and collapse row groups.

Row Group Component

LyteNyte Grid exports the RowGroupCell component to handle row group expansion and collapse. It provides the following built-in functionality:

  • Expand and collapse group nodes.
  • Prevent expansion for non-expandable group nodes.
  • Display loading indicators during expansion.
  • Display error indicators if expansion fails.

LyteNyte Grid’s RowGroupCell component significantly reduces boilerplate compared with a custom implementation.

As shown in the demo below, the Group column uses the RowGroupCell component to render group expansion and to handle out-of-the-box group label retrieval.

Row Group Cell

Fork code on stack blitzFork code on code sandbox

The code below shows a basic example of configuring a group cell. The RowGroupCell component is a cell renderer and must be provided with all required cell renderer properties.

const group: Grid.RowGroupColumn<GridSpec> = {
cellRenderer: RowGroupCell,
width: 200,
pin: "start",
};

Row Group Cell Styling

The RowGroupCell component is unstyled by default. You can style the component using the data attributes applied to the group cell elements. If you are using one of the prebuilt grid themes, the group cell styling is already included.

To create or customize group cell styles, refer to the example CSS below. The prebuilt themes use this CSS as a reference implementation.

[data-ln-component-group-cell] {
display: flex;
7 collapsed lines
align-items: center;
box-sizing: border-box;
width: 100%;
height: 100%;
gap: 8px;
padding-inline-start: calc(var(--ln-space-40) * var(--ln-row-depth));
&[data-ln-component-group-cell-expandable="false"]:not([data-ln-component-group-cell-depth="0"]) {
/* Space 60 for the icon and 8px for the gap. */
padding-inline-start: calc(var(--ln-space-40) * var(--ln-row-depth) + var(--ln-space-60));
}
&[data-ln-component-group-cell-expanded="true"]
[data-ln-component-group-cell-expander="true"]:not([data-ln-component-group-cell-error="true"]) {
transform: rotate(90deg);
}
&[data-ln-component-group-cell-expanded="true"] [data-ln-component-group-cell-error="true"] {
color: var(--ln-red-50);
}
& [data-ln-component-group-cell-expander="true"] {
18 collapsed lines
border-radius: var(--ln-radius-field-md);
background-color: transparent;
border: transparent;
display: flex;
align-items: center;
justify-content: center;
width: var(--ln-space-60);
height: var(--ln-space-60);
min-width: var(--ln-space-60);
min-height: var(--ln-space-60);
max-width: var(--ln-space-60);
max-height: var(--ln-space-60);
margin-inline-start: calc(var(--ln-padding-horizontal-cell) * -1 + 3px);
&:hover {
background-color: var(--ln-bg-button-light);
cursor: pointer;
}
}
}

Row Group Cell Properties

The RowGroupCell component is a cell renderer. To pass additional props, wrap RowGroupCell in a custom component and forward the props. The wrapper must implement the cell renderer interface.

The example below uses this pattern to add custom leaf-row labels to the row group cell.

function MyGroupCell(props: Grid.T.CellRendererParams) {
return (
<RowGroupCell
{...props}
leafLabel={(row, api) => {
if (!row.parentId) return <div className="ps-2.5">{row.data.job}</div>;
const parent = api.rowById(row.parentId);
if (parent?.kind === "branch" && row.depth === 1) {
return <div className="ps-6.5 font-bold">{row.data.marital ?? "(blank)"}</div>;
}
return "";
}}
/>
);
}

The RowGroupCell component extends CellParamsWithIndex. The properties listed below are additional properties supported by the component.

Prop

Next Steps

  • Menu Button: Display a list of actions or options in an accessible dropdown menu.
  • Smart Select: Streamline data selection using a versatile combobox or select element.
  • Row Group Cell: Handle expansion and collapse interactions for grouped rows.