Home > sculp-js > getPathById
getPathById() function
Retrieves the path (ancestors + self) for a given node ID.
Signature:
typescript
export declare function getPathById<V>(tree: ArrayLike<V>, nodeId: IdLike, options?: ITreeConf): [(number | string)[], any[]];Parameters
Parameter | Type | Description |
|---|---|---|
tree |
| Tree data |
nodeId | Target node ID | |
options | (Optional) Configuration. Default: { childField = 'children', keyField = 'id' } |
Returns:
[(number | string)[], any[]]
{[(number | string)[], V[]]} - Array of IDs and Array of Nodes from root to target