RevoGrid has two different ways to show hierarchical rows, and they solve different problems:
Key grouping uses the grid’s built-in grouping configuration, for example grid.grouping = { props: ['country', 'city'] }. The grid reads one or more column values, creates synthetic group header rows for each matching key, and places source rows under those generated groups. Use it when the hierarchy should be calculated from repeated values such as category, region, status, or date.
TreeDataPlugin uses explicit row relationships from your data, normally id and parentId. The plugin keeps your original rows as the tree nodes, computes tree metadata such as level, expanded state, and visibility, and trims collapsed descendants from the viewport. Use it when the hierarchy already exists in the data, such as folders, tasks and subtasks, organization charts, bill of materials, or nested records.
In short, key grouping answers “which rows share the same values?”, while the tree plugin answers “which row is the parent of this row?”. Key grouping is value-driven and creates group rows; tree data is relationship-driven and renders your existing rows as parent and child nodes.
Key Features
Hierarchical Data Support: Automatically organizes flat data into a tree
structure based on customizable id, parentId, and level fields. -
Expandable Rows: Expand and collapse rows dynamically to reveal or hide
child rows. - Customizable Templates: Supports tree-specific cell
templates for better customization. - Root Parent Support: Define custom
root parent identifiers for flexibility in tree structure.
The plugin supports the following options for customization:
idField: Defines the field representing unique row identifiers. Default: ‘id’.
parentIdField: Specifies the field indicating parent row IDs. Default: ‘parentId’.
levelField: Sets the field to store hierarchy levels. Default: ‘level’.
rootParentId: Defines the identifier for root-level rows. Default: ‘root’.
expandedRowIds: A Set of row IDs to predefine expanded rows.
selectionFilterMode: Checkbox filters default to 'exclude-subtree', which hides complete unchecked branches. Use 'match-path' to keep ancestors of checked children and descendants of checked parents visible as context. Gantt enables 'match-path' for its task table.
Use expandRowsById() to reveal several branches in one tree update. It preserves existing expanded rows and skips updates when all supplied IDs are already expanded.
Tree rows can animate while they are trimmed during collapse and restored during expand. Enable tree.animation; TreeDataPlugin registers DimensionAnimationPlugin automatically when it is not already present.