Skip to main content
cngx-src documentation

CngxTreeControllerOptions

Interface

projects/common/interactive/tree-controller/tree-controller.ts

Import#

import { CngxTreeControllerOptions } from '@cngx/common/interactive'

Description#

Configuration for createTreeController.

nodeIdFn is required on purpose: the controller hands its ids out to expandedIds, to selection memoization (keyFn consumers), and to the stable-identity isExpanded(id) signal cache. A non-stable id (e.g. the path-based fallback from flattenTree) silently breaks all three the moment the tree is sorted or filtered - exactly the Sort/Filter integration pattern this stack is designed to support. Forcing the caller to think about identity at construction eliminates that whole class of heisenbugs.

Index#

Instance Properties#

cacheLimit#number
ReadonlyOptional

Bound the isExpanded(id) signal cache. Default: unlimited. Resolution: per-options > provideTreeConfig.cacheLimit > unlimited. See CngxTreeConfig.cacheLimit for trade-offs.

initiallyExpanded#"all" | "none" | unknown
ReadonlyOptional

Initial expansion. Resolution: per-options > provideTreeConfig.defaultInitiallyExpanded > 'none'. Evaluated once at construction; later tree changes do not re-apply. Re-trigger via expandAll() if needed.

ReadonlyOptional

Membership key. Defaults (in resolution order): per-options > provideTreeConfig default > identity.

labelFn#function
ReadonlyOptional

Visible label. Defaults (in resolution order): per-options > provideTreeConfig default > String(value).

nodeIdFn#function
ReadonlyOptional

Derives a stable id per flat node - must survive re-ordering and filtering of the source tree. Use a domain id ((v) => v.id) rather than a positional fallback.

Resolution: per-options > app-wide provideTreeConfig default > dev-mode error. At least one source must provide the function.

nodes#Signal[]>
Readonly

Source tree - the controller re-derives on every change.