Skip to main content
Version: 7.9

Tree View

Component Palette Icon:

Description

The Tree View component can display any tree hierarchy. It is configured by filling in a dataset. Each row in the dataset will become a node in the tree. Each node has a path, for example, "West Area/Process/Valve1" that determines its location in the tree. The Separation Character property (by default it is forward-slash), dictates how the paths are broken up. Any missing folder nodes needed by a leaf node are created implicitly.

The other columns in the dataset besides "Path" are used to configure the look for the node, both when it is selected and when it is not. This component recognizes the following column titles. The references to optional column titles means that a dataset does not need to have them present in the dataset for the tree to render and function.

  • Path - the path determines the node's location. Broken up into a list by splitting on the separation character.
  • Text - the text of the node while not selected.
  • Icon - a path to an icon for the node. Use the value: "default" to use the tree automatic folder/leaf icons. [optional]
  • Background - a string column that will be coerced into a color for the unselected background. e.g. "white" or "(255,255,255)" Use an empty string to use the default color.[optional]
  • Foreground - a string representation of the unselected foreground color. [optional]
  • Tooltip - if not empty, will be used as the tooltip for the node.[optional]
  • Border - a string that will be coerced into a Border for the node while unselected. May be empty.[optional]
  • SelectedText - the text of the node while selected.[optional]
  • SelectedIcon - a path to an icon for the node while selected. Use the value: "default" to use the tree automatic folder/leaf icons.[optional]
  • SelectedBackground - a string representation of the selected foreground color.[optional]
  • SelectedForeground - a string representation of the selected foreground color.[optional]
  • SelectedTooltip - if not empty, will be used as the tooltip for the node while selected.[optional]
  • SelectedBorder - a string that will be coerced into a Border for the node while selected. May be empty.[optional]

Below is an example configuration of the treeview's items property. Notice how not all of the fields listed above are used, because there are certain properties that are not necessary to build our treeview. Notice how I have chosen a larger version of the same images for the Selected Icon, so that when an item gets selected, not only does the background color change, but the size of the image changes as well.

PathTextIconBackgroundForegroundSelectedTextSelectedIconSelectedBackgroundSelectedForeground
HMI ScreensOverviewBuiltin/icons/16/home.pngcolor(255, 255, 255, 255)color(0, 0, 0, 255)OverviewBuiltin/icons/24/home.pngcolor(250, 214, 138, 255)color(0,0,0,255)
Administration/UsersUser ManagementBuiltin/icons/16/users3.pngcolor(255, 255, 255, 255)color(0, 0, 0, 255)User ManagementBuiltin/icons/24/users3.pngcolor(250, 214, 138, 255)color(0,0,0,255)
Administration/UsersSchedule ManagementBuiltin/icons/16/calendar.pngcolor(255, 255, 255, 255)color(0, 0, 0, 255)Schedule ManagementBuiltin/icons/24/calendar.pngcolor(250, 214, 138, 255)color(0,0,0,255)
AdministrationRoster ManagementBuiltin/icons/16/clock.pngcolor(255, 255, 255, 255)color(0, 0, 0, 255)Roster ManagementBuiltin/icons/24/clock.pngcolor(250, 214, 138, 255)color(0,0,0,255)

Properties

NameDescriptionProperty TypeScriptingCategory
AntialiasDraw with antialias on? Makes text smoother.boolean.antialiasAppearance
Auto ExpandIf true, the tree will automatically expand the tree structure up to the level specified by Auto Expansion Level.boolean.autoExpandBehavior
Auto Expansion LevelIf Auto Expand is true, this is the depth level that will be expanded. Zero means expand-all.int.autoExpansionLevelBehavior
Auto SortWhether or not to automatically sort the tree.boolean.autoSortBehavior
Background ColorThe background color of the component.Color.backgroundAppearance
BorderThe border surrounding this component. NOTE that the border is unaffected by rotation.Border.borderCommon
Data QualityThe data quality code for any tag bindings on this component.int.dataQualityData
Default Closed IconThe default closed icon if no icon is set.String.defaultClosedIconPathAppearance
Default Leaf IconThe default leaf icon if no icon is set.String.defaultLeafIconPathAppearance
Default Node BackgroundThe default background of a node if no background is set.Color.defaultBackgroundAppearance
Default Node BorderThe default border of a node if no border is set.Border.defaultBorderAppearance
Default Node ForegroundThe default foreground of a node if no foreground is set.Color.defaultForegroundAppearance
Default Node Selected BackgroundThe default selected background of a node if no background is set.Color.defaultSelectedBackgroundAppearance
Default Node Selected BorderThe default selected border of a node if no border is set.Border.defaultSelectedBorderAppearance
Default Node Selected ForegroundThe default selected foreground of a node if no foreground is set.Color.defaultSelectedForegroundAppearance
Default Open IconThe default open icon if no icon is set.String.defaultOpenIconPathAppearance
EnabledIf disabled, a component cannot be used.boolean.componentEnabledCommon
FontFont of text on this component.Font.fontAppearance
ItemsContains the items of the tree view.Dataset.dataData
Line StyleThe tree's line style.int.lineStyleAppearance
Mouseover TextThe text that is displayed in the tooltip which pops up on mouseover of this component.String.toolTipTextCommon
NameThe name of this component.String.nameCommon
Row HeightThe height of each row in the tree.int.rowHeightAppearance
Selected ItemThe index of the currently selected item, or -1 if no selection.int.selectedItemData
Selected PathThe path of the currently selected item, or "" if no selection.String.selectedPathData
Selection ModeWhat kind of selection regions does the tree allow.int.selectionModeBehavior
Separation CharacterThe separation character for the path.String.separationCharacterBehavior
Show Root HandlesWhether or not to show handles next to parent nodes.boolean.showRootHandlesAppearance
VisibleIf disabled, the component will be hidden.boolean.visibleCommon

Scripting

See the Tree View Scripting Functions page for the full list of scripting functions available for this component.

Event Handlers

Event handlers allow you to run a script based off specific triggers. See the full list of available event handlers on the Component Events page.

Customizers

The tree view customizer allows for easy custom manipulation of the tree view components underlying formatting.

Examples

Expression Snippet
//The Selected Item property will be updated as the user selects different nodes in the tree. 
//It represents the index in the Items dataset at which the node is defined. If the selected
//node was implicitly created, the Selected Item will be -1.
//You can use this index to get the path and name of the selected node with an expression binding like this:
if ({Root Container.Tree View.selectedItem}<0,"n/a",{Root Container.Tree View.data}[{Root Container.Tree View.selectedItem},"text"])
Script Snippet
#This script will swap to the script that was double clicked on, if this code is placed in the mouseClicked event handler for the treeview
#This script utilizes an extra column called windowPath that contains the full path to the window. You can add an extra column to the Items dataset property
#as long as the column name doesn't match one of the reserved column titles listed above.
if event.clickCount == 2:
row = event.source.selectedItem
data = event.source.data
if row != -1:
# Grab the window path value out of the tree view's items dataset
windowPath = data.getValueAt(row, "windowPath")
system.nav.swapTo(windowPath)