Class YAHOO.widget.TreeView

Object
   |
   +--YAHOO.widget.TreeView

class YAHOO.widget.TreeView

Field Summary [top]

String id
The id of tree container element 
boolean locked
We lock the tree control while waiting for the dynamic loader to return 
int maxAnim
The maximum number of animations to run at one time. 
int nodeCount
Count of all nodes in all trees 

Constructor Summary [top]

YAHOO.widget.TreeView
Contains the tree view state data and the root node. 

Method Summary [top]

boolean animateCollapse (el)
Perform the collapse animation if configured, or just show the element if not configured or too many animations are in progress 
boolean animateExpand (el)
Perform the expand animation if configured, or just show the element if not configured or too many animations are in progress 
void collapseAll ()
Collapses all expanded child nodes in the entire tree. 
void collapseComplete ()
Function executed when the collapse animation completes 
void draw ()
Renders the tree boilerplate and visible nodes 
void expandAll ()
Expands all child nodes. 
void expandComplete ()
Function executed when the expand animation completes 
Object generateId (el)
private 
HTMLElement getEl ()
Returns the tree's host element 
Node getNodeByIndex (<int> nodeIndex)
Returns a node in the tree that has the specified index (this index is created internally, so this function probably will only be used in html generated for a given node.) 
Node getNodeByProperty (<object> property, <object> value)
Returns a node that has a matching property and value in the data object that was passed into its constructor. 
Array getNodesByProperty (<object> property, <object> value)
Returns a collection of nodes that have a matching property and value in the data object that was passed into its constructor. 
Node getRoot ()
Returns the root node of this tree 
void onCollapse (node)
Abstract method that is executed when a node is collapsed 
void onExpand (node)
Abstract method that is executed when a node is expanded 
void popNode (node)
Removes the node from the tree, preserving the child collection to make it possible to insert the branch into another part of the tree, or another tree. 
void removeChildren (<Node> node)
Deletes this nodes child collection, recursively. 
boolean removeNode (node, <boolean> autoRefresh)
Removes the node and its children, and optionally refreshes the branch of the tree that was affected. 
void setCollapseAnim (type)
Sets up the animation for collapsing children 
void setDynamicLoad (<function> fnDataLoader, iconMode)
Configures this tree to dynamically load all child data 
void setExpandAnim (type)
Sets up the animation for expanding children 
string toString ()
toString 
void addHandler (el, <string> sType, <function> fn, <boolean> capture)
Adds an event. 
Node getNode (treeId, nodeIndex)
Global method for getting a node by its id. 
TreeView getTree (treeId)
Global method for getting a tree by its id. 
void preload (prefix)
Attempts to preload the images defined in the styles used to draw the tree by rendering off-screen elements that use the styles. 

Field Detail [top]

id

String   id
The id of tree container element

locked

boolean   locked
We lock the tree control while waiting for the dynamic loader to return

maxAnim

int   maxAnim
The maximum number of animations to run at one time.

nodeCount

int   nodeCount
Count of all nodes in all trees

Constructor Detail [top]

YAHOO.widget.TreeView

YAHOO.widget.TreeView ()
Contains the tree view state data and the root node. This is an ordered tree; child nodes will be displayed in the order created, and there currently is no way to change this.
Parameters:
string - |HTMLElement} id The id of the element, or the element itself that the tree will be inserted into.

Method Detail [top]

animateCollapse

boolean animateCollapse (el)
Perform the collapse animation if configured, or just show the element if not configured or too many animations are in progress
Parameters:
el - {HTMLElement} the element to animate
Returns:
true if animation could be invoked, false otherwise

animateExpand

boolean animateExpand (el)
Perform the expand animation if configured, or just show the element if not configured or too many animations are in progress
Parameters:
el - {HTMLElement} the element to animate
Returns:
true if animation could be invoked, false otherwise

collapseAll

void collapseAll ()
Collapses all expanded child nodes in the entire tree.

collapseComplete

void collapseComplete ()
Function executed when the collapse animation completes

draw

void draw ()
Renders the tree boilerplate and visible nodes

expandAll

void expandAll ()
Expands all child nodes. YAHOO.widget.TreeView.prototype.Note = this;conflicts with the "multiExpand" node property. If expand all is called in a tree with nodes that do not allow multiple siblings to be displayed, only the last sibling will be expanded.

expandComplete

void expandComplete ()
Function executed when the expand animation completes

generateId

Object generateId (el)
private

getEl

HTMLElement getEl ()
Returns the tree's host element
Returns:
the host element

getNodeByIndex

Node getNodeByIndex (<int> nodeIndex)
Returns a node in the tree that has the specified index (this index is created internally, so this function probably will only be used in html generated for a given node.)
Parameters:
nodeIndex - the index of the node wanted
Returns:
the node with index=nodeIndex, null if no match

getNodeByProperty

Node getNodeByProperty (<object> property, <object> value)
Returns a node that has a matching property and value in the data object that was passed into its constructor.
Parameters:
property - the property to search (usually a string)
value - the value we want to find (usuall an int or string)
Returns:
the matching node, null if no match

getNodesByProperty

Array getNodesByProperty (<object> property, <object> value)
Returns a collection of nodes that have a matching property and value in the data object that was passed into its constructor.
Parameters:
property - the property to search (usually a string)
value - the value we want to find (usuall an int or string)
Returns:
the matching collection of nodes, null if no match

getRoot

Node getRoot ()
Returns the root node of this tree
Returns:
the root node

onCollapse

void onCollapse (node)
Abstract method that is executed when a node is collapsed
Parameters:
node - {Node} the node that was collapsed.

onExpand

void onExpand (node)
Abstract method that is executed when a node is expanded
Parameters:
node - {Node} the node that was expanded

popNode

void popNode (node)
Removes the node from the tree, preserving the child collection to make it possible to insert the branch into another part of the tree, or another tree.
Parameters:
the - node to remove

removeChildren

void removeChildren (<Node> node)
Deletes this nodes child collection, recursively. Also collapses the node, and resets the dynamic load flag. The primary use for this method is to purge a node and allow it to fetch its data dynamically again.
Parameters:
node - the node to purge

removeNode

boolean removeNode (node, <boolean> autoRefresh)
Removes the node and its children, and optionally refreshes the branch of the tree that was affected.
Parameters:
autoRefresh - automatically refreshes branch if true
The - node to remove
Returns:
False is there was a problem, true otherwise.

setCollapseAnim

void setCollapseAnim (type)
Sets up the animation for collapsing children
Parameters:
the - type of animation (acceptable values defined in YAHOO.widget.TVAnim)

setDynamicLoad

void setDynamicLoad (<function> fnDataLoader, iconMode)
Configures this tree to dynamically load all child data
Parameters:
fnDataLoader - the function that will be called to get the data
iconMode - {int} configures the icon that is displayed when a dynamic load node is expanded the first time without children. By default, the "collapse" icon will be used. If set to 1, the leaf node icon will be displayed.

setExpandAnim

void setExpandAnim (type)
Sets up the animation for expanding children
Parameters:
the - type of animation (acceptable values defined in YAHOO.widget.TVAnim)

toString

string toString ()
toString
Returns:
string representation of the tree

addHandler

void addHandler (el, <string> sType, <function> fn, <boolean> capture)
Adds an event. Replace with event manager when available
Parameters:
el - the elment to bind the handler to
sType - the type of event handler
fn - the callback to invoke
capture - if true event is capture phase, bubble otherwise

getNode

Node getNode (treeId, nodeIndex)
Global method for getting a node by its id. Used in the generated tree html.
Parameters:
treeId - {String} the id of the tree instance
nodeIndex - {String} the index of the node to return
Returns:
the node instance requested, null if not found

getTree

TreeView getTree (treeId)
Global method for getting a tree by its id. Used in the generated tree html.
Parameters:
treeId - {String} the id of the tree instance
Returns:
the tree instance requested, null if not found.

preload

void preload (prefix)
Attempts to preload the images defined in the styles used to draw the tree by rendering off-screen elements that use the styles.