View as Markdown

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

TreeStructureinterface

import type { TreeStructure } from '@salmonui/data-grid/engine/tree';
interface TreeStructure {
    readonly index: TreeLayout;
    readonly layout: TreeLayout;
    readonly sourceIds: readonly RowId[];
    sourceIndexOf(rowId: RowId): number;
    readonly parentIdField: string | null;
    readonly nested?: boolean;
    withParent(row: unknown, parentId: RowId | null): unknown;
}

Tree reads the selection, editing, and row drag modules use through treeOf(model) (view-helpers.ts) without importing tree code: the full (unfiltered) tree and the kept layout of the current query.

TreeStructure members (7)
NameSignatureDescription
indexreadonly index: TreeLayout;

Every source row (unfiltered, source sibling order).

layoutreadonly layout: TreeLayout;

Rows kept by the current query, in sorted sibling order.

sourceIdsreadonly sourceIds: readonly RowId[];
sourceIndexOfsourceIndexOf(rowId: RowId): number;

Source index of a row id, or -1.

parentIdFieldreadonly parentIdField: string | null;

parentIdField of flat data, or null for nested data.

nestedoptionalreadonly nested?: boolean;

Parents come from the nesting (childrenField): moves keep the new parent through tree.setParents.

withParentwithParent(row: unknown, parentId: RowId | null): unknown;

Returns a copy of row with its parent set (flat data), or null when the shape cannot express it (moves then dispatch tree.setParents).