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

Tree Editing

Edit the nested tree data object using the grid's cell editing capabilities.

Note

This guide assumes familiarity with cell editing. Read the Cell Editing guide for more details.

Editing Tree Cells

To edit a tree cell, make the column for that cell editable and provide an editRenderer component. You must also set the editMode property on the grid to "cell" or "row".

When a cell is edited, LyteNyte Grid calls the onRowDataChange method on the tree data source. Set the onRowDataChange property on the useTreeDataSource hook to handle these data updates.

The onRowDataChange handler receives the applied cell changes, along with any data changes applied to rows pinned to the top or bottom of the grid. The full function interface is shown below:

type OnTreeRowDataChange = (params: {
readonly changes: { next: object; prev: object; parent: object; key: string; path: string[] }[];
readonly top: Map<number, T>;
readonly bottom: Map<number, T>;
}) => void;

The demo below shows tree cell editing. Double-click a cell in the Size column to start editing.

Tree Data Editing

Fork code on stack blitzFork code on code sandbox

Editing Tree Groups

To enable group cell editing, replace the LyteNyte Group column with a custom group column. First, set rowGroupColumn to false to prevent the grid from creating an automatic group column.

Next, add a custom group column to your definitions. Since you define this column, set the editable and editRenderer properties to enable editing.

The demo below replaces the Group column with a custom Files column. Double-click a file name cell to edit it.

Note

The demo sorts rows by Size. Renaming a group can change the branch order when the underlying JavaScript object is updated. Sorting by Size ensures the rows maintain a stable order.

Tree Group Editing

Fork code on stack blitzFork code on code sandbox

Next Steps

  • Cell Editing: Edit cell values and commit updates in the grid.
  • Tree Filtering: Remove tree data rows by providing a custom filter function.
  • Tree Data: Generate hierarchical rows from nested object data.