TreeList(options)

new TreeList(options)

Create a tree list view with interactive nodes

This component will build a hierarchical tree with given model. The model must fit the format described in the README.md. Each node can then be expanded or collapsed if it contains children. Each node will also fire a given callback when clicked, sending its information so further handling can be done on the caller side. It finally expose some global method to update the tree by code (expand or collapse all).
Parameters:
Name Type Description
options object

The TreeList global options

Properties
Name Type Attributes Description
renderTo object

The DOM element to render the TreeList in

model Array.<object>

The model to build the TreeList with. Must match the format described on this component's repository

nodeClicked function <optional>

The callback function to provided that will be called each time a node is clicked

Since:
  • October 2020
Author:
  • Arthur Beaulieu

Members

private _container :object

The DOM element to render the TreeList in

private _nodeClicked :function

The callback function to provided that will be called each time a node is clicked

private _nodes :array

Nodes that have a depth of 0. Child nodes are available and hierarchical

Methods

private, static _buildModel(model)

This method will build the TreeList using the provided model. It build the tree nodes recursively, so they match the hierarchical format given as input model.
Parameters:
Name Type Description
model object

The model to build the TreeList with. Must match the format described on this component's repository

private, static _buildNode(nodeModel, depth) → {object}

This method will build the TreeList using the provided model. It build the tree nodes recursively, so they match the hierarchical format given as input model.
Parameters:
Name Type Description
nodeModel object

The node model that contains its information

Properties
Name Type Attributes Default Description
id number <optional>
-1

The node ID

name number

The node name to display in TreeList

children array

The node children

depth number

The node depth in graph

Returns:
object -

The TreeListNode object

private, static _buildUI()

This method will attach root nodes (depth 0) to the TreeList UI.

static collapseAll()

This method will collapse all nodes in the TreeList recursively.

static destroy()

TreeList destructor. Will delete each nodes, their events and their properties.

static expandAll()

This method will expand all nodes in the TreeList recursively.