BiTreeDataModel

This data model takes a tree consisting of BiTreeNode2 nodes and exposes the interface needed by the BiTreeView. The internal tree does not have to be a BiTreeNode2 as long as getNodeChildren, getNodeHashCode, getCellText and getSortFunction (if sorting is needed) are overridden. The default implementation assumes that the data in the BiTreeNode2 objects are arrays containing the cell data.

This class extends BiTreeViewDataModel and therefore all methods and fields available for BiTreeViewDataModel are also available for BiTreeDataModel .

Constructor

new BiTreeDataModel ( oRootNode )

Parameters

NameTypeOptionalDefaultDescripton
oRootNodeBiTreeNode2The optional node to act as the root for the data

Properties

NameTypegetsetDescripton
rootNodevoidcheckedcheckedThe tree node that is the root of the data

Methods

NameDescription
getExpandedWhether the node at a certain row is expanded or not. Do not override this method. If the expanded implementation needs to change, override BiTreeDataModel.prototype._getNodeExpanded(oNode) instead.
getNodeAtThis returns the node at the given row
getNodeChildrenThis returns the children of the tree node that is the root of the data. This should be overridden if your nodes are not instances of BiTreeNode2
getNodeHashCodeReturns a hash code for the node. It is useful to override this if you are building your own custom tree model that does not use BiTreeNode2 as your tree nodes.
insertRowAtinserts a new object into the tree rows
rebuildSubtreeThis removes all the nodes in the subtree and readds them, basically refreshing the tree. This also fires a rowcountchanged event so that the view is refreshed
rebuildTreeThis will rebuild the internal tree structure and refresh the view.
removeRowAtRemoves the row at the given row. This also removes any possible subtree of the node
setExpandedSets whether the node at a certain row is expanded or not. Do not override this method. If the expanded implementation needs to change, override BiTreeDataModel.prototype._setNodeExpanded(oNode,b) instead.

Events

NameTypeBubblesDescripton
beforecollapseBiTreeViewDataModelEventThis event is fired before a row is collapsed
beforeexpandBiTreeViewDataModelEventThis event is fired before a row is expanded
collapseBiTreeViewDataModelEventThis event is fired when a row has collapsed
datachangedBiTreeViewDataModelEventThis event is fired when the data changes.
expandBiTreeViewDataModelEventThis event is fired when a row has expanded
rowcountchangedBiTreeViewDataModelEventThis event is fired when the row count changes. The rowIndex and the rowCount properties on the event object are available for this event

Static Methods

None.

Static Fields

None.

Remarks

None.

Method Details

getExpanded

Whether the node at a certain row is expanded or not. Do not override this method. If the expanded implementation needs to change, override BiTreeDataModel.prototype._getNodeExpanded(oNode) instead.

Syntax

object.getExpanded ( y )

Parameters

NameTypeOptionalDefaultDescripton
yNumberthe index of the row

Return Type

Boolean

getNodeAt

This returns the node at the given row

Syntax

object.getNodeAt ( y )

Parameters

NameTypeOptionalDefaultDescripton
yNumberThe index of the row

Return Type

BiTreeNode2

getNodeChildren

This returns the children of the tree node that is the root of the data. This should be overridden if your nodes are not instances of BiTreeNode2

Syntax

object.getNodeChildren ( oNode )

Parameters

NameTypeOptionalDefaultDescripton
oNodeBiTreeNode2The object that acts as the root node

Return Type

BiTreeNode2[]

getNodeHashCode

Returns a hash code for the node. It is useful to override this if you are building your own custom tree model that does not use BiTreeNode2 as your tree nodes.

Syntax

object.getNodeHashCode ( oNode )

Parameters

NameTypeOptionalDefaultDescripton
oNodeBiTreeNode2The node to get the hash code for

Return Type

String

insertRowAt

inserts a new object into the tree rows

Syntax

object.insertRowAt ( obj [ ,nParentRowIndex [ ,nChildIndex ] ] )

Parameters

NameTypeOptionalDefaultDescripton
objBiTreeNode2The object describing the data
nParentRowIndexNumbercheckedThe index of the parent row. If this is null or -1 then the row is added to the implicit root.
nChildIndexNumbercheckedThe position of the new child. If left out then the new node is appended at the end.

Return Type

void

rebuildSubtree

This removes all the nodes in the subtree and readds them, basically refreshing the tree. This also fires a rowcountchanged event so that the view is refreshed

Syntax

object.rebuildSubtree ( nIndex )

Parameters

NameTypeOptionalDefaultDescripton
nIndexNumberThe index of the node to refresh the subtree for

Return Type

void

rebuildTree

This will rebuild the internal tree structure and refresh the view.

Syntax

object.rebuildTree ( )

Parameters

No arguments.

Return Type

void

removeRowAt

Removes the row at the given row. This also removes any possible subtree of the node

Syntax

object.removeRowAt ( y )

Parameters

NameTypeOptionalDefaultDescripton
yNumberthe row to remove

Return Type

void

setExpanded

Sets whether the node at a certain row is expanded or not. Do not override this method. If the expanded implementation needs to change, override BiTreeDataModel.prototype._setNodeExpanded(oNode,b) instead.

Syntax

object.setExpanded ( y,b [ ,preventUpdate ] )

Parameters

NameTypeOptionalDefaultDescripton
yNumberthe index of the row
bBooleanwhether the node should be expanded
preventUpdateBooleancheckedwhether to update the tree or not (useful when changing many nodes at the same time. Note that you need to let the tree update on the last node that is updated.

Return Type

void