BiTree

This class is used for showing a tree, a column list and a combined tree with multiple columns. The control also provides headers that can be used to resize the columns, reorder the columns or sort the data by

This class extends BiAbstractGrid and therefore all methods and fields available for BiAbstractGrid are also available for BiTree .

Constructor

new BiTree ( )

Parameters

No parameters.

Properties

Name Type get set Descripton
depth Number checked The depth of the tree
expanded Boolean checked checked Whether the node is expanded or not. The tree control is always expanded so setting this to false has no effect. This is provided so that the tree has the same interface as the tree nodes.
firstNode BiTreeNode checked Returns the first child node.
indentColumn Number checked checked The column to indent by. Setting this to -1 (or a value greater than the column count) removes the indentation.
indentWidth Number checked checked The amount to indent child nodes
lastNode BiTreeNode checked Returns the last child node.
level Number checked The level of indention for the tree. This is -1 for the actual tree
nextSiblingNode BiTreeNode checked Returns the next tree node sibling. This is null for the actual tree control.
nodes BiTreeNode[] checked Returns all the child nodes.
parentNode BiTreeNode checked Returns the parent tree node. This is null for the actual tree control.
previousSiblingNode BiTreeNode checked Returns the previous tree node sibling. This is null for the actual tree control.
showLines Boolean checked checked Whether to show the lines in the tree
showPlusMinus Boolean checked checked Whether to show the expand and collapse icons
showRootLines Boolean checked checked Whether to show lines on the top most level

Methods

Name Description
addNode Adds a tree node as a child to the tree
containsNode Whether the tree contains the node
getNodeAtPoint Returns the tree node at the given point. If no node is found this returns null.
getRowAtPoint Returns the row at the given point. If no node is found this returns null. This is the same as getNodeAtPoint
hasNodes Returns true if the tree has any child nodes
isLastSiblingNode Returns true if the node has no next sibling node. This is always true for the tree component.
isLeaf Returns true if the tree has no child nodes
removeAll Removes all child nodes (and disposes them)
removeNode Removes a tree node child
reveal Expands all parent tree nodes to make this item visible This doesn't really do anything for BiTree but it is provided to have the same interface as BiTreeNode

Events

Name Type Bubbles Descripton
change BiEvent Fires when the selected row/cell changes
expandedchanged BiEvent Fires when the tree is expanded or collapsed and the lead item is changed.

Static Methods

None.

Static Fields

None.

Remarks

Before drawing the tree you need to set the columnCount. You most likely also want to set the columnWidths, columnSortTypes, columnNames, indentColumn and the iconColumn. Below is a typical tree: var tree = new BiTree; tree.setColumnCount(3); tree.setColumnWidths([100,50,150]); tree.setColumnNames(["Name", "Size", "Date"]); tree.setColumnSortTypes(["CaseInsensitiveString", "Number", "Date"]); tree.setColumnAligns(["left", "right", "left"]); tree.setIndentColumn(0); tree.setIconColumn(0); // add tree nodes parentComponent.add(tree); tree.update(); Make sure that the tree is created when you call the update methods or they will not do anything. When modifying a tree always call update() or the tree body and/or the columns will not be displayed correctly. You should also be careful not to update the tree when not necessary because the update methods are expansive.

Method Details

addNode

Adds a tree node as a child to the tree

Syntax

object.addNode
 (
 oChild
 [
 ,oBefore
 ]
 
 )
 

Parameters

Name Type Optional Default Descripton
oChild BiTreeNode The tree node child to add
oBefore BiTreeNode checked If provided, the child is added before this node

Return Type

void

containsNode

Whether the tree contains the node

Syntax

object.containsNode
 (
 oDescendant
 )
 

Parameters

Name Type Optional Default Descripton
oDescendant BiTreeNode The node to test if it is contained

Return Type

Boolean

getNodeAtPoint

Returns the tree node at the given point. If no node is found this returns null.

Syntax

object.getNodeAtPoint
 (
 nClientX,nClientY
 )
 

Parameters

Name Type Optional Default Descripton
nClientX Number The left position relative to the browser window
nClientY Number The top position relative to the browser window

Return Type

BiTreeNode

getRowAtPoint

Returns the row at the given point. If no node is found this returns null. This is the same as getNodeAtPoint

Syntax

object.getRowAtPoint
 (
 nClientX,nClientY
 )
 

Parameters

Name Type Optional Default Descripton
nClientX Number The left position relative to the browser window
nClientY Number The top position relative to the browser window

Return Type

BiTreeNode

hasNodes

Returns true if the tree has any child nodes

Syntax

object.hasNodes
 (
 
 )
 

Parameters

No arguments.

Return Type

Boolean

isLastSiblingNode

Returns true if the node has no next sibling node. This is always true for the tree component.

Syntax

object.isLastSiblingNode
 (
 
 )
 

Parameters

No arguments.

Return Type

Boolean

isLeaf

Returns true if the tree has no child nodes

Syntax

object.isLeaf
 (
 
 )
 

Parameters

No arguments.

Return Type

Boolean

removeAll

Removes all child nodes (and disposes them)

Syntax

object.removeAll
 (
 
 )
 

Parameters

No arguments.

Return Type

void

removeNode

Removes a tree node child

Syntax

object.removeNode
 (
 oChild
 )
 

Parameters

Name Type Optional Default Descripton
oChild BiTreeNode The node to remove

Return Type

BiTreeNode

reveal

Expands all parent tree nodes to make this item visible This doesn't really do anything for BiTree but it is provided to have the same interface as BiTreeNode

Syntax

object.reveal
 (
 
 )
 

Parameters

No arguments.

Return Type

void