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
| Name | Type | Optional | Default | Descripton |
oRootNode | | The optional node to act as the root for the data |
Properties
| Name | Type | get | set | Descripton |
rootNode | void | ![]() | ![]() | The tree node that is the root of the data |
Methods
| Name | Description |
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. |
getNodeAt | This returns the node at the given row |
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 |
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. |
insertRowAt | inserts a new object into the tree rows |
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 |
rebuildTree | This will rebuild the internal tree structure and refresh the view. |
removeRowAt | Removes the row at the given row. This also removes any possible subtree of the node |
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. |
Events
| Name | Type | Bubbles | Descripton |
beforecollapse | | This event is fired before a row is collapsed | |
beforeexpand | | This event is fired before a row is expanded | |
collapse | | This event is fired when a row has collapsed | |
datachanged | | This event is fired when the data changes. | |
expand | | This event is fired when a row has expanded | |
rowcountchanged | | This 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
| Name | Type | Optional | Default | Descripton |
y | Number | the index of the row |
Return Type
Boolean
getNodeAt
This returns the node at the given row
Syntax
object.getNodeAt ( y ) Parameters
| Name | Type | Optional | Default | Descripton |
y | Number | The index of the row |
Return Type
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
| Name | Type | Optional | Default | Descripton |
oNode | | The object that acts as the root node |
Return Type
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
| Name | Type | Optional | Default | Descripton |
oNode | | The 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
| Name | Type | Optional | Default | Descripton |
obj | | The object describing the data | ||
nParentRowIndex | Number | ![]() | The index of the parent row. If this is null or -1 then the row is added to the implicit root. | |
nChildIndex | Number | ![]() | The 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
| Name | Type | Optional | Default | Descripton |
nIndex | Number | The 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
| Name | Type | Optional | Default | Descripton |
y | Number | the 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
| Name | Type | Optional | Default | Descripton |
y | Number | the index of the row | ||
b | Boolean | whether the node should be expanded | ||
preventUpdate | Boolean | ![]() | whether 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
