LyteNyte Grid logo for light mode. Links back to the documentation home page.
Client Row Source

Client Row Group Collapsing

Row grouping transforms row data into a tree structure. LyteNyte Grid flattens this tree if a row group contains only a single leaf child.

To collapse group rows that contain a single child row automatically, set rowGroupCollapseBehavior on the client data source to one of the following values:

  • “full-tree”: Collapse group rows with a single child at every depth.
  • “last-only”: Collapse group rows with a single child only at the final depth level.
  • “no-collapse”: Do not collapse any group rows. This is the default.

Full Tree Collapsing

Setting rowGroupCollapseBehavior to "full-tree" collapses group rows that have a single child at every depth level. Use the "full-tree" setting when you want a grouping tree that is as flat as possible without losing information.

Full Tree Collapsing

Fork code on stack blitzFork code on code sandbox

Note

To clearly demonstrate the "full-tree" collapse behavior, the sample data includes only a single row for the Blue-Collar job category.

Last Only Collapsing

Setting rowGroupCollapseBehavior to "last-only" collapses only the final group row when it has a single child. Unlike "full-tree", the client data source does not collapse parent groups after collapsing the final group, as the demo below shows.

Last Row Group Collapsing

Fork code on stack blitzFork code on code sandbox

In the demo, the Blue-Collar group has a single child. However, because the grid uses two grouping levels, only the last level is collapsed.

Updating Collapse Settings

You can update rowGroupCollapseBehavior dynamically. In this demo, useState manages the property value, which updates via a toggle group to demonstrate the different behaviors.

Updating Collapse Behavior

Fork code on stack blitzFork code on code sandbox

Next Steps