Class Tree

Object
   |
   +--TreeNode
         |
         +--Tree

class Tree
extends TreeNode

This class provides the methods to create an HTML tree dynamically. Creation usually takes the following form:

var tree = new Tree ('my tree');

var firstChild  = tree.createNode (icon, 'tooltip text 1', value1);
var secondChild = tree.createNode (icon, 'tooltip text 2', value2);

tree.appendChild (firstChild);
tree.appendChild (secondChild);

tree.refresh();
tree.show();


Constructor Summary
Tree (name)
           
 
Method Summary
 function clear()
           Removes all tree nodes except for the root node.
 function createNode(icon, tooltip, value, target)
           Creates a new tree node.
 function getNode(id)
           Returns the node for the given branch id.
 function hide()
           Hides the tree (default).
 function refresh()
           Updates the HTML document (the tree view).
 function show()
           Visualizes the tree.
 function updateDOM(node)
           Private method used by the refresh() routine.
 
Methods inherited from class TreeNode
appendChild, firstChild, lastChild, nextSibling, isLastSibling, removeChild, hasChildren, getAllChildren
 

Constructor Detail

Tree

function Tree(name)

Parameters:
name - Tree name (warning: The name must be unique in case there are multiple trees within a single HTML document.)

Method Detail

clear

function clear()
Removes all tree nodes except for the root node.


createNode

function createNode(icon, tooltip, value, target)
Creates a new tree node.

Parameters:
target - Tree event callbacks class instance, may be omitted.

value - The tree node text.

icon - The tree node icon (size must be 19x16)

tooltip - The popup text shown when hoovering with the mouse over the tree node icon.

Returns:
The created node.

getNode

function getNode(id)
Returns the node for the given branch id. The branch id represents the node position within the tree. For a tree with two child nodes this will be for example:
root:                  id = 0
first child of root:   id = 0_1
second child of root:  id = 0_2

Parameters:
id - Branch id of the requested node.

Returns:
The node for the given branch id or null if not present.

hide

function hide()
Hides the tree (default).


refresh

function refresh()
Updates the HTML document (the tree view). This routine must be called after modifying the tree to visualize the changes.


show

function show()
Visualizes the tree.


updateDOM

function updateDOM(node)
Private method used by the refresh() routine.