Skip to content

Treeview

Screenshot

An interactive tree used for navigation, integrated with view state parameters

Basics

Screenshot

Data Source
The TreeView data source should include integer data columns for Node Id and Parent node, and a text label column.
Data sources
Node ID
The data source column of unique integer values for each folder and item in the TreeView. Node IDs are used to define which items are checked, opened or selected. This is a required column
Parent nodes

A data source column which defines the TreeView layout. Start by defining which nodes are to be part of the top level directory; these are assigned a null value based on the kdb type used. Each node sharing a value will be part of same level; for example, the top level of an integer based hierarchy treeview must have a Parent nodes value of 0Ni; the next level in the TreeView would use a Parent node value of 1i etc. Nested items in a tree should all be assigned the same Parent node values. This is a required column.

For example, Parent Nodes defined by parentId (null values are underlined, with an alternative date type hierarchy given in parentId2) in the following query:

Screenshot

generates this layout:

Screenshot

Text
The data source column containing the label for each folder and item. This is a required column
Icon

If an icon marker is to be used in place of the standard folder icon, then define the data source column containing the list of Fontawesome (fa fa-image or fas fa-image formats), 64-bit or image URL links.

Screenshot

Opened nodes
Define which set of Nodes will be open on load.
Opened Nodes ID

A view state parameter of Node IDs, type symbol, bound to expanded parent folders. Expanded nodes will display all child items.

Default values

Default Opened Nodes ID values, if set, will be superseded by Opened Nodes ID values assigned by the data source. If Opened Nodes has no corresponding data source column, then default Open Nodes ID values will be used if assigned.

Checked Nodes ID

A view state parameter of Node IDs, type symbol, bound to all checked items in the tree - including parent folder node ID/s.

Default values

Default Checked Nodes ID values, if set, will be superseded by Checked Nodes values assigned by the data source.

Check Parent
Parent node (box) is checked on load.
Selected Node ID

A view state parameter of a single Node ID, type symbol, bound to an individually selected item, either a parent folder or child item.

Selected vs Checked

The Selected Node ID is a single Node ID of the currently selected item in the tree view, which may or may not be checked - only one item can be selected at any one time (parent or child). Checked items are tracked by Checked Nodes ID.

Default values

Default Selected Node ID value, if set, will be superseded by a value assigned by the data source.

Check on Selected
Check (box) when selecting nodes.
Open on Selected
Selecting the node name will expand child elements.
Template Text

Formats tree labels

Text-append example

Interactive tree nodes with a parentId value of 1, precede node text with "Grand Prix Season:"

html {{#lt parentId 1}} Grand Prix Season: {{names}}{{/lt}}{{#gte parentId 1}}{{names}}{{/gte}}

Template

Action

Actions

Style, Margins and Format

The treenode Node Id must be referenced when applying CSS styles to icons in the treeview. For example, this is the CSS for the earlier Treeview using fontawesome icons:

[data-widgetid="xxxx-xxxx-xxxx-xxxx"] 
    div.treeview-container .treenode-id-x.jstree-leaf 
    > .jstree-anchor 
    > i.jstree-icon.jstree-themeicon.fa.jstree-themeicon-custom 
    {color: brown; }

where xin .treenode-id-x.jstree-leaf is the corresponding Node Id integer value, and data-widgetid is the TreeView component widget id.

Style