Tree
new Tree(delegate, root, parentContainer, options)
Tree view control
Parameters
delegate* object | TreeDelegate instance |
root* object | A node in the model Document |
parentContainer* HTMLElement, string | Or parentContainerId |
options* object |
Methods
destroy()
Remove tree from DOM.
show(show)
Show/hide the tree control
Parameters
show* boolean | true to show the tree control, false to hide it |
getRootContainer()
Get the root container
Returns
type | description |
---|---|
string |
getElementForNode(node)
Get DOM element for a given logical tree node (or its integer id)
Parameters
node* object | Tree node element |
Returns
type | description |
---|---|
HTMLElement |
delegate()
Get the tree delegate
Returns
type | description |
---|---|
object | TreeDelegate instance |
isCollapsed(group)
Is the given group node in the tree collapsed?
Parameters
group* object | The group node |
Returns
type | description |
---|---|
boolean | true if group node is collapsed, false if expanded |
setCollapsed(group, collapsed, recursive)
Collapse/expand the given group node in the tree
Parameters
group* object | the group node |
collapsed* boolean | Set to true to collapse the group node, false to expand it |
recursive* boolean | Set to true to make it recursive |
setAllCollapsed(collapsed)
Collapse/expand all group nodes in the tree
Parameters
collapsed* boolean | true to collapse tree, false to expand it |
addToSelection(nodes)
Add the given nodes to the current selection
Parameters
nodes* Array.<object> | nodes to add to the current selection |
removeFromSelection(nodes)
Remove the given nodes from the current selection
Parameters
nodes* Array.<object> | The nodes to remove from the current selection |
setSelection(nodes)
Set the current selection
Parameters
nodes* Array.<object> | nodes to make currently selected |
getSelection()
Get the current selection
Returns
type | description |
---|---|
Array.<object> | selected nodes. |
clearSelection()
Clear the current selection
isSelected(node)
Is the given node selected?
Parameters
node* object | The tree node |
Returns
type | description |
---|---|
boolean |
|
scrollTo(node)
Scrolls the container to reveal the node’s DOM element.
Parameters
node* object | the Tree node |
addClass(node, className, recursive)
Add a CSS class to a node
Parameters
node* number, object | The tree node |
className* string | |
recursive* |
Returns
type | description |
---|---|
boolean |
|
removeClass(node, className, recursive)
Remove a class from a node
Parameters
node* number, object | The tree node or its dbId |
className* string | Class name |
recursive* boolean | Set to true to make it recursive |
Returns
type | description |
---|---|
boolean |
|
hasClass(node, className)
Does the node have the given class?
Parameters
node* number, object | The node or its dbId |
className* string |
Returns
type | description |
---|---|
boolean | true if the node has the given class, false otherwise |
clear()
Clears the contents of the tree
iterate(node, callback)
Iterates through nodes in the tree in pre-order.
Parameters
node* object, number | node at which to start the iteration. |
callback* function | invoked for each iterated node with (Object, HTMLElement) |