Skip to content

Home > sculp-js > formatTree

formatTree() function

Converts a flat array into a tree structure.

Signature:

typescript
export declare function formatTree(list: any[], options?: IFieldOptions): any[];

Parameters

Parameter

Type

Description

list

any[]

Flat list of items

options

IFieldOptions

(Optional) Customizes id field name, child element field name, parent element field name. Default: { keyField: 'key', childField: 'children', pidField: 'pid' }

Returns:

any[]

{any[]} Tree structure array

Released under the MIT License.