HierarchyPlugin
Since v3.9.0
Hierarchy Plugin for tbw-grid
Builds one hierarchical row model from every attached structure contributor
— TreePlugin discovers
child rows, GroupingRowsPlugin
groups sibling lists — and announces each row’s position with the WAI-ARIA
treegrid pattern (aria-level / aria-setsize / aria-posinset).
Contributors know nothing about each other, so they compose: a grid with both Tree and GroupingRows groups the children of every tree level.
You never need to add this plugin yourself — TreePlugin and GroupingRowsPlugin declare it as a dependency and the grid attaches it automatically. It has no configuration.
Example
Section titled “Example”Group the children of every tree node
Section titled “Group the children of every tree node”import { TreePlugin } from '@toolbox-web/grid/plugins/tree';import { GroupingRowsPlugin } from '@toolbox-web/grid/plugins/grouping-rows';
grid.gridConfig = { plugins: [ new TreePlugin({ childrenField: 'children' }), new GroupingRowsPlugin({ // Leave the root level ungrouped, group every child level by kind groupOn: (row, { depth }) => (depth > 0 ? row.kind : null), }), ],};Extends BaseGridPlugin
Inherited methods like
attach(),detach(),afterRender(), etc. are documented in the base class.
Methods
Section titled “Methods”process() v3.9.0+
Section titled “process() v3.9.0+”Build the row model for a contributor’s processRows hook.
Every contributor forwards its hook here; only the one that runs last in
the processRows pipeline builds the model (for all contributors at
once) — the earlier ones pass their rows through untouched.
process(rows: readonly unknown[], caller: HierarchyContributor): unknown[]Parameters
Section titled “Parameters”| Name | Type | Description |
|---|---|---|
rows | readonly unknown[] | |
caller | HierarchyContributor |
Example
Section titled “Example”override processRows(rows: readonly unknown[]): unknown[] { return this.grid.getPluginByName('hierarchy')?.process(rows, this) ?? [...rows];}getRowMeta() v3.9.0+
Section titled “getRowMeta() v3.9.0+”Hierarchy position of a row in the current row model, or undefined when
the row is not rendered (e.g. collapsed under a parent).
getRowMeta(row: unknown): HierarchyRowMeta | undefinedParameters
Section titled “Parameters”| Name | Type | Description |
|---|---|---|
row | unknown |
Example
Section titled “Example”const meta = grid.getPluginByName('hierarchy')?.getRowMeta(grid.rows[0]);console.log(meta?.level, meta?.posInSet, meta?.setSize);