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 | ![]() | The depth of the tree | |
expanded | Boolean | ![]() | ![]() | 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 | | ![]() | Returns the first child node. | |
indentColumn | Number | ![]() | ![]() | The column to indent by. Setting this to -1 (or a value greater than the column count) removes the indentation. |
indentWidth | Number | ![]() | ![]() | The amount to indent child nodes |
lastNode | | ![]() | Returns the last child node. | |
level | Number | ![]() | The level of indention for the tree. This is -1 for the actual tree | |
nextSiblingNode | | ![]() | Returns the next tree node sibling. This is null for the actual tree control. | |
nodes | | ![]() | Returns all the child nodes. | |
parentNode | | ![]() | Returns the parent tree node. This is null for the actual tree control. | |
previousSiblingNode | | ![]() | Returns the previous tree node sibling. This is null for the actual tree control. | |
showLines | Boolean | ![]() | ![]() | Whether to show the lines in the tree |
showPlusMinus | Boolean | ![]() | ![]() | Whether to show the expand and collapse icons |
showRootLines | Boolean | ![]() | ![]() | 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 | | Fires when the selected row/cell changes | |
expandedchanged | | Fires 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
| Name | Type | Optional | Default | Descripton |
oChild | | The tree node child to add | ||
oBefore | | ![]() | 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 | | 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
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
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 | | The node to remove |
Return Type
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
