buildHierarchy
Since v3.9.0
Build the flat row list for rows from every contributor’s sibling-list
transforms, recording each emitted row’s ARIA position in meta.
Contributors whose beginHierarchy returns false sit out the rebuild.
With no active contributor the rows pass through unchanged. When every
active contributor’s endHierarchy returns false, no position is kept in meta.
This is what HierarchyPlugin.process() runs for all attached contributors.
Call it directly to run a contributor without a grid — e.g. as the
processRows fallback when no HierarchyPlugin is attached, or in unit tests.
function buildHierarchy(rows: readonly unknown[], contributors: readonly HierarchyContributor[], meta: WeakMap<object, HierarchyRowMeta>, substitute: (row: unknown) => unknown): unknown[]Parameters
Section titled “Parameters”| Name | Type | Description |
|---|---|---|
rows | readonly unknown[] | The root rows. |
contributors | readonly HierarchyContributor[] | Contributors to run, in processRows hook order. |
meta | WeakMap<object, HierarchyRowMeta> | Receives each emitted row’s position. Pass a fresh map per rebuild. |
substitute | (row: unknown) => unknown | Optional. Maps a row to the object to use in its place, at |
| every nesting level, before any contributor sees it. Return the row itself to | ||
keep it. HierarchyPlugin uses this to keep a row being edited when the data | ||
| is replaced with new objects. Added in 3.10.2. |
Example
Section titled “Example”override processRows(rows: readonly unknown[]): unknown[] { const hierarchy = this.grid?.getPluginByName('hierarchy'); return hierarchy ? hierarchy.process(rows, this) : buildHierarchy(rows, [this]);}