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

> The parentsFromNested function of @salmonui/data-grid/engine/tree: Parents of nested rows that are already in flat pre-order (flattenTree output). One parallel walk of the nesting and the flat array; when the flat array is not exactly the flattening (rows appended by a patch, or reordered), falls back to an identity map, O(n) either way. A child object that is not in rows (a parent replaced with copies of its children) is matched through indexOfRow (the row id) when given. Rows that are nobody's child are roots.

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

```ts
import { parentsFromNested } 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 parentsFromNested(rows: readonly unknown[], childrenField: string, indexOfRow?: (row: unknown) => number): Int32Array;
```

Parents of nested rows that are already in flat pre-order (`flattenTree`
output). One parallel walk of the nesting and the flat array; when the
flat array is not exactly the flattening (rows appended by a patch, or
reordered), falls back to an identity map, O(n) either way. A child object
that is not in `rows` (a parent replaced with copies of its children) is
matched through `indexOfRow` (the row id) when given. Rows that are
nobody's child are roots.
