BiTreeNode

This represents a tree node for a tree or a row for a tree. A tree node is not a component but it has some visual properties that are similar to a component.

When working with trees and column list it is usually suitable to extend this class instead of using it directly because this gives better control over what data is bound to the node and what text to show on the row.

This class extends BiAbstractGridRow and therefore all methods and fields available for BiAbstractGridRow are also available for BiTreeNode .

Constructor

new BiTreeNode ( [ oData ] )

Parameters

Name Type Optional Default Descripton
oData Object[] checked [] This is an array containing the data to be used for each column.

Properties

Name Type get set Descripton
cssClassName String checked Returns the CSS class name used for the row of the node.
depth Number checked The depth of the tree
expanded Boolean checked checked Whether the node is expanded or not.
expandIconHtml String checked Returns the HTML used to draw the expand icon.
expandIconSrc String checked Returns the URI to the image file that should be used for the expand icon.
firstNode BiTreeNode checked Returns the first child node.
grid BiTree checked Returns the tree component that the node is part of. Same as tree
html String checked Returns the HTML for the node and all its children. This is used by the BiTree treeBodyHtml property when drawing the tree.
iconHtml String checked Returns the HTML used to draw the icon.
lastNode BiTreeNode checked Returns the last child node.
level Number checked The level of indention for the tree.
nextSiblingNode BiTreeNode checked Returns the next tree node sibling (if any).
nodes BiTreeNode[] checked Returns all the child nodes.
parentNode BiTreeNode / BiTree checked Returns the parent tree node.
previousSiblingNode BiTreeNode checked Returns the previous tree node sibling (if any).
rowHtml String checked Returns the HTML for the row of the node. This does not include any of the child nodes for the tree node.
tree BiTree checked Returns the tree component that the node is part of

Methods

Name Description
addNode Adds a tree node as a child to the current tree node
containsNode Whether the tree node contains another node
getCellHtml Returns the HTML for the entire cell (includes indention, expand icon and icon)
getData Returns the data for the given column index
getLabelHtml Returns the actual HTML to show on the cell. Override this to handle specific data. The default implementation uses String(treeNode.getData(nCol))
hasNodes Returns true if the tree node has any child nodes
isLastSiblingNode Returns true if the node has no next sibling node.
isLeaf Returns true if the tree node has no child nodes
removeAll Removes all child nodes (and disposes them)
removeNode Removes a tree node child
removeNodeAt Removes the tree node child at the given index
reveal Expands all parent tree nodes to make this node visible
setData Sets the data for a given column index
toggle Toggles the expand property
update Updates the node and all of its children. This allows the tree to redraw only the current branch of the tree. This is useful when only a few items have changed and therefore the whole data of the tree does not need to be redrawn.
updateRow Updates the row of the tree node. This allows the tree to redraw only the current tree item row (the children are not redrawn). This is useful when only a few items have changed and therefore the whole data of the tree does not need to be redrawn.

Events

None.

Static Methods

None.

Static Fields

None.

Remarks

Changing the node does not automatically update the tree. The tree will have to be updated manually.

Method Details

addNode

Adds a tree node as a child to the current tree node

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 node contains another node

Syntax

object.containsNode
 (
 oDescendant
 )
 

Parameters

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

Return Type

Boolean

getCellHtml

Returns the HTML for the entire cell (includes indention, expand icon and icon)

Syntax

object.getCellHtml
 (
 nCol
 )
 

Parameters

Name Type Optional Default Descripton
nCol Number The column to get the cell HTML for

Return Type

String

getData

Returns the data for the given column index

Syntax

object.getData
 (
 x
 )
 

Parameters

Name Type Optional Default Descripton
x Number The column index of the column to get the data for

Return Type

Object

getLabelHtml

Returns the actual HTML to show on the cell. Override this to handle specific data. The default implementation uses String(treeNode.getData(nCol))

Syntax

object.getLabelHtml
 (
 nCol
 )
 

Parameters

Name Type Optional Default Descripton
nCol Number The column to get the label html for

Return Type

String

hasNodes

Returns true if the tree node has any child nodes

Syntax

object.hasNodes
 (
 
 )
 

Parameters

No arguments.

Return Type

Boolean

isLastSiblingNode

Returns true if the node has no next sibling node.

Syntax

object.isLastSiblingNode
 (
 
 )
 

Parameters

No arguments.

Return Type

Boolean

isLeaf

Returns true if the tree node 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

removeNodeAt

Removes the tree node child at the given index

Syntax

object.removeNodeAt
 (
 i
 )
 

Parameters

Name Type Optional Default Descripton
i Number The index of the node to remove

Return Type

BiTreeNode

reveal

Expands all parent tree nodes to make this node visible

Syntax

object.reveal
 (
 
 )
 

Parameters

No arguments.

Return Type

void

setData

Sets the data for a given column index

Syntax

object.setData
 (
 x,oData
 )
 

Parameters

Name Type Optional Default Descripton
x Number The index of the column to set the data for
oData Object The data to set on the given column

Return Type

void

toggle

Toggles the expand property

Syntax

object.toggle
 (
 
 )
 

Parameters

No arguments.

Return Type

void

update

Updates the node and all of its children. This allows the tree to redraw only the current branch of the tree. This is useful when only a few items have changed and therefore the whole data of the tree does not need to be redrawn.

Syntax

object.update
 (
 
 )
 

Parameters

No arguments.

Return Type

void

updateRow

Updates the row of the tree node. This allows the tree to redraw only the current tree item row (the children are not redrawn). This is useful when only a few items have changed and therefore the whole data of the tree does not need to be redrawn.

Syntax

object.updateRow
 (
 
 )
 

Parameters

No arguments.

Return Type

void