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

NameTypeOptionalDefaultDescripton
oDataObject[]checked[] This is an array containing the data to be used for each column.

Properties

NameTypegetsetDescripton
cssClassNameStringcheckedReturns the CSS class name used for the row of the node.
depthNumbercheckedThe depth of the tree
expandedBooleancheckedcheckedWhether the node is expanded or not.
firstNodeBiTreeNodecheckedReturns the first child node.
gridBiTreecheckedReturns the tree component that the node is part of. Same as tree
htmlStringcheckedReturns the HTML for the node and all its children. This is used by the BiTree treeBodyHtml property when drawing the tree.
iconHtmlStringcheckedReturns the HTML used to draw the icon.
lastNodeBiTreeNodecheckedReturns the last child node.
levelNumbercheckedThe level of indention for the tree.
nextSiblingNodeBiTreeNodecheckedReturns the next tree node sibling (if any).
nodesBiTreeNode[]checkedReturns all the child nodes.
parentNodeBiTreeNode / BiTreecheckedReturns the parent tree node.
previousSiblingNodeBiTreeNodecheckedReturns the previous tree node sibling (if any).
rowHtmlStringcheckedReturns the HTML for the row of the node. This does not include any of the child nodes for the tree node.
treeBiTreecheckedReturns the tree component that the node is part of

Methods

NameDescription
addNodeAdds a tree node as a child to the current tree node
containsNodeWhether the tree node contains another node
getCellHtmlReturns the HTML for the entire cell (includes indention, expand icon and icon)
getDataReturns the data for the given column index
getExpandIconHtmlReturns the HTML used to draw the expand icon.
getExpandIconSrcReturns the URI to the image file that should be used for the expand icon.
getLabelHtmlReturns the actual HTML to show on the cell. Override this to handle specific data. The default implementation uses String(treeNode.getData(nCol))
hasNodesReturns true if the tree node has any child nodes
isLastSiblingNodeReturns true if the node has no next sibling node.
isLeafReturns true if the tree node has no child nodes
removeAllRemoves all child nodes (and disposes them)
removeNodeRemoves a tree node child
removeNodeAtRemoves the tree node child at the given index
revealExpands all parent tree nodes to make this node visible
setDataSets the data for a given column index
toggleToggles the expand property
updateUpdates 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.
updateRowUpdates 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

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

Return Type

void

containsNode

Whether the tree node contains another node

Syntax

object.containsNode ( oDescendant )

Parameters

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

NameTypeOptionalDefaultDescripton
nColNumberThe column to get the cell HTML for

Return Type

String

getData

Returns the data for the given column index

Syntax

object.getData ( x )

Parameters

NameTypeOptionalDefaultDescripton
xNumberThe column index of the column to get the data for

Return Type

Object

getExpandIconHtml

Returns the HTML used to draw the expand icon.

Syntax

object.getExpandIconHtml ( [ bRtl ] )

Parameters

NameTypeOptionalDefaultDescripton
bRtlbooleancheckedWether to use right to left or not

Return Type

String

getExpandIconSrc

Returns the URI to the image file that should be used for the expand icon.

Syntax

object.getExpandIconSrc ( [ bRtl ] )

Parameters

NameTypeOptionalDefaultDescripton
bRtlbooleancheckedWether to use right to left or not

Return Type

String

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

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

NameTypeOptionalDefaultDescripton
oChildBiTreeNodeThe node to remove

Return Type

BiTreeNode

removeNodeAt

Removes the tree node child at the given index

Syntax

object.removeNodeAt ( i )

Parameters

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

NameTypeOptionalDefaultDescripton
xNumberThe index of the column to set the data for
oDataObjectThe 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