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

NameTypegetsetDescripton
depthNumbercheckedThe depth of the tree
expandedBooleancheckedcheckedWhether 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.
firstNodeBiTreeNodecheckedReturns the first child node.
indentColumnNumbercheckedcheckedThe column to indent by. Setting this to -1 (or a value greater than the column count) removes the indentation.
indentWidthNumbercheckedcheckedThe amount to indent child nodes
lastNodeBiTreeNodecheckedReturns the last child node.
levelNumbercheckedThe level of indention for the tree. This is -1 for the actual tree
nextSiblingNodeBiTreeNodecheckedReturns the next tree node sibling. This is null for the actual tree control.
nodesBiTreeNode[]checkedReturns all the child nodes.
parentNodeBiTreeNodecheckedReturns the parent tree node. This is null for the actual tree control.
previousSiblingNodeBiTreeNodecheckedReturns the previous tree node sibling. This is null for the actual tree control.
showLinesBooleancheckedcheckedWhether to show the lines in the tree
showPlusMinusBooleancheckedcheckedWhether to show the expand and collapse icons
showRootLinesBooleancheckedcheckedWhether to show lines on the top most level

Methods

NameDescription
addNodeAdds a tree node as a child to the tree
containsNodeWhether the tree contains the node
getNodeAtPointReturns the tree node at the given point. If no node is found this returns null.
getRowAtPointReturns the row at the given point. If no node is found this returns null. This is the same as getNodeAtPoint
hasNodesReturns true if the tree has any child nodes
isLastSiblingNodeReturns true if the node has no next sibling node. This is always true for the tree component.
isLeafReturns true if the tree has no child nodes
removeAllRemoves all child nodes (and disposes them)
removeNodeRemoves a tree node child
revealExpands 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

NameTypeBubblesDescripton
changeBiEventFires when the selected row/cell changes
expandedchangedBiEventFires when a node in the tree is expanded or collapsed.

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

NameTypeOptionalDefaultDescripton
oChildBiTreeNodeThe tree node child to add
oBeforeBiTreeNodecheckedIf provided, the child is added before this node

Return Type

void

containsNode

Whether the tree contains the node

Syntax

object.containsNode ( oDescendant )

Parameters

NameTypeOptionalDefaultDescripton
oDescendantBiTreeNodeThe 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

NameTypeOptionalDefaultDescripton
nClientXNumberThe left position relative to the browser window
nClientYNumberThe 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

NameTypeOptionalDefaultDescripton
nClientXNumberThe left position relative to the browser window
nClientYNumberThe 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

NameTypeOptionalDefaultDescripton
oChildBiTreeNodeThe 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