View as Markdown

API reference: @salmonui/data-grid/engine/tree

TreeMethodstype

import type { TreeMethods } from '@salmonui/data-grid/engine/tree';
type TreeMethods<Row> = {
    getTreeRow(ctx: ModuleContext<Row>, rowId: RowId): TreeRowInfo | null;
    getChildRows(ctx: ModuleContext<Row>, rowId: RowId | null): readonly Row[];
    getChildRowIds(ctx: ModuleContext<Row>, rowId: RowId | null): readonly RowId[];
    isExpanded(ctx: ModuleContext<Row>, rowId: RowId): boolean;
    getLoadStatus(ctx: ModuleContext<Row>, rowId: RowId): TreeLoadStatus;
    checkState(ctx: ModuleContext<Row>, rowId: RowId): TreeCheckState;
    getChildSummary(ctx: ModuleContext<Row>, rowId: RowId): AggregateValues | null;
    canIndent(ctx: ModuleContext<Row>, rowIds: readonly RowId[]): boolean;
    canOutdent(ctx: ModuleContext<Row>, rowIds: readonly RowId[]): boolean;
    getExpansion(ctx: ModuleContext<Row>): {
        readonly expandedRows: Readonly<Record<RowId, boolean>>;
        readonly defaultExpanded: boolean | number;
    };
    getInfo(ctx: ModuleContext<Row>): TreeInfo;
};
TreeMethods members (11)
NameSignatureDescription
getTreeRowgetTreeRow(ctx: ModuleContext<Row>, rowId: RowId): TreeRowInfo | null;

Row info for the renderer and getRowInfo(); null for unknown rows.

getChildRowsgetChildRows(ctx: ModuleContext<Row>, rowId: RowId | null): readonly Row[];

Kept children of a row in view order (null: the roots).

getChildRowIdsgetChildRowIds(ctx: ModuleContext<Row>, rowId: RowId | null): readonly RowId[];
isExpandedisExpanded(ctx: ModuleContext<Row>, rowId: RowId): boolean;
getLoadStatusgetLoadStatus(ctx: ModuleContext<Row>, rowId: RowId): TreeLoadStatus;
checkStatecheckState(ctx: ModuleContext<Row>, rowId: RowId): TreeCheckState;

Checkbox tri-state derived from selected descendants (aria-checked="mixed").

getChildSummarygetChildSummary(ctx: ModuleContext<Row>, rowId: RowId): AggregateValues | null;

Child summary values of a parent (over its kept descendants), or null without aggregates.

canIndentcanIndent(ctx: ModuleContext<Row>, rowIds: readonly RowId[]): boolean;

Can tree.indent / tree.outdent move these rows (toolbar disabled state)?

canOutdentcanOutdent(ctx: ModuleContext<Row>, rowIds: readonly RowId[]): boolean;
getExpansiongetExpansion(ctx: ModuleContext<Row>): { readonly expandedRows: Readonly<Record<RowId, boolean>>; readonly defaultExpanded: boolean | number; };

Persistable expansion (getState().tree).

getInfogetInfo(ctx: ModuleContext<Row>): TreeInfo;