class Tree

Extends:
UIComponent

Description:

A Tree component shows a list items but in a child/parent structure.

Like in a List component the items can hold custom id and value data in addition to text, icon, tooltip, font object, background, and color.

The Tree component can be customized the way it's displayed by methods Tree > showRoot, Tree > showRootHandle, Tree > showIcons, and Tree > expanded.

Items are identified by their unique index path, which is an array of each index, starting from root element [0]. Example index of an item can be [0, 3, 2] where first element is an index of root element (always [0]), and child's index, and then its child.

Items can be easily added using Tree > add, removed using Tree > remove, updated and retrieved using Tree > item, and moved from one parent to another using Tree > moveItem.

All other Tree methods not on this page are inherited from UIComponent.

Constructor

constructor([root_text])

Creates an instance of Tree component object.

Parameters:

Name Type Description

[root_text]

string

Text to be displayed in the root element. Root element may not be visible if not set to be visible with showRootHandle(true).

Members

Methods

From this class:

Inherited from UIComponent:

Examples:

// Format of tree item object (Only "text" is requited, other fields are optional)
{
    text: string,           // Item text (Required)
    [id]: string|number,    // Value that can be used by software logic to identify this item
    [value]: string|number, // Additional value to be stored in the item for later use.
    [icon]: string,         // Absolute or relative path to icon image, base64 encoded image string, or `null` to remove icon.
    [color]: string,        // Item text color as a 6 character hex encoded color string (e.g. #665500)
    [background]: string,   // Item background color as a 6 character hex encoded color string (e.g. #665500)
    [tooltip]: string,      // Tooltip text to show when pointer hover the item. (in List and Tree components only)
    [font]: font object     // Object{name: string, size: number, bold: boolean, ...}. See complete list of font properties in example of font() method.
    [children]:object[]     // An array of children (when adding or recursively retrieving).
}