Hierarchy API
GridApi<T> inherits HierarchyApi<T>, providing methods to inspect display nodes, toggle expansion, and persist state.
Inspecting & Controlling Nodes
Section titled “Inspecting & Controlling Nodes”import { decodeHierarchyKey, encodeHierarchyKey } from 'next-grid-js';
const node = grid.getDisplayedRowNode(0);if (node?.kind === 'group') { grid.setGroupExpanded({ kind: 'node', key: node.key }, true); grid.ensureDisplayNodeVisible({ kind: 'node', key: node.key }, 'start');}
grid.expandAllGroups();grid.collapseAllGroups();
const counts = grid.getHierarchyCounts();const hierarchyState = grid.getGroupingState();
// Canonical key helpersconst encoded = encodeHierarchyKey('EMEA');const original = decodeHierarchyKey(encoded);DisplayNode<T>Kinds:'leaf','tree'(hasData: true | false),'group', and'aggregate'(totalKind: 'groupTotal' | 'grandTotal').- State Persistence:
getState()serializeshierarchy(mode, columns,valueColumns,aggregationScope,groupTotals,grandTotal, andexpansion: { defaultExpandedDepth, overrides }). Always retainnode.key(notnodeId) for structural commands.