# buildTreeLayout (@salmonui/data-grid/engine/tree)

> The buildTreeLayout function of @salmonui/data-grid/engine/tree: Builds the pre-order of the rows kept by keep (null: every row). priority lists source indexes in sibling order (the sort stage's order; null: source order); kept rows missing from it follow in source order. Rows whose parent is not kept hang under the nearest kept ancestor (root when none). base, the source order layout of every row under parent (buildTreeLayout(parent, null, null)), makes a re-order or an ancestor closed filter (filterMode 'ancestors' / 'both') skip the tree walk. O(n).

Canonical: https://salmonui.dev/docs/reference/data-grid/engine-tree/buildTreeLayout

```ts
import { buildTreeLayout } from '@salmonui/data-grid/engine/tree';
```

Entry index: https://salmonui.dev/docs/reference/data-grid/engine-tree (Markdown with every symbol of the entry: https://salmonui.dev/docs/reference/data-grid/engine-tree.md).

## Reference

Kind: function

```ts
function buildTreeLayout(parent: Int32Array, priority: Int32Array | null, keep: Uint8Array | null, base?: TreeLayout | null): TreeLayout;
```

Builds the pre-order of the rows kept by `keep` (null: every row).
`priority` lists source indexes in sibling order (the sort stage's order;
null: source order); kept rows missing from it follow in source order.
Rows whose parent is not kept hang under the nearest kept ancestor (root
when none). `base`, the source order layout of every row under `parent`
(`buildTreeLayout(parent, null, null)`), makes a re-order or an ancestor
closed filter (`filterMode` `'ancestors'` / `'both'`) skip the tree walk.
O(n).
