Print Friendly

Class YAHOO.widget.TreeView

Package:YAHOO.widget
Class:TreeView
Extends:Object
Defined In:treeview.js
Contains the tree view state data and the root node.

Public Properties

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

Public Methods

Method Defined By
  TreeView(string|HTMLElement id) TreeView
  addHandler<static>(el the, string sType, function fn) : void TreeView
<static> Add a DOM event
  animateCollapse(el {HTMLElement}, node {YAHOO.util.Node}) : boolean TreeView
Perform the collapse animation if configured, or just show the element if not configured or too many animations are i...
  animateExpand(el {HTMLElement}, node {YAHOO.util.Node}) : boolean TreeView
Perform the expand animation if configured, or just show the element if not configured or too many animations are in ...
  collapseAll() : void TreeView
Collapses all expanded child nodes in the entire tree.
  collapseComplete() : void TreeView
Function executed when the collapse animation completes
  draw() : void TreeView
Renders the tree boilerplate and visible nodes
  expandAll() : void TreeView
Expands all child nodes. Note: this conflicts with the "multiExpand" node property. If expand all is called in a tr...
  expandComplete() : void TreeView
Function executed when the expand animation completes
  getEl() : HTMLElement TreeView
Returns the tree's host element
  getNode<static>(treeId {String}, nodeIndex {String}) : Node TreeView
<static> Global method for getting a node by its id. Used in the generated tree html.
  getNodeByIndex(int nodeIndex) : Node TreeView
Returns a node in the tree that has the specified index (this index is created internally, so this function probably ...
  getNodeByProperty(object property, object value) : Node TreeView
Returns a node that has a matching property and value in the data object that was passed into its constructor.
  getNodesByProperty(object property, object value) : Array TreeView
Returns a collection of nodes that have a matching property and value in the data object that was passed into its co...
  getRoot() : Node TreeView
Returns the root node of this tree
  getTree<static>(treeId {String}) : TreeView TreeView
<static> Global method for getting a tree by its id. Used in the generated tree html.
  onCollapse(node {Node}) : void TreeView
Deprecated. Abstract method that is executed when a node is collapsed.
  onExpand(node {Node}) : void TreeView
Deprecated. Abstract method that is executed when a node is expanded
  popNode(Node the) : void TreeView
Removes the node from the tree, preserving the child collection to make it possible to insert the branch into anothe...
  preload<static>(string prefix) : void TreeView
<static> Attempts to preload the images defined in the styles used to draw the tree by rendering off-screen ele...
  removeChildren(Node node) : void TreeView
Deletes this nodes child collection, recursively. Also collapses the node, and resets the dynamic load flag. The pr...
  removeHandler<static>(el the, string sType, function fn) : void TreeView
<static> Remove a DOM event
  removeNode(Node The, boolean autoRefresh) : boolean TreeView
Removes the node and its children, and optionally refreshes the branch of the tree that was affected.
  setCollapseAnim(string the) : void TreeView
Sets up the animation for collapsing children
  setDynamicLoad(function fnDataLoader, iconMode {int}) : void TreeView
Configures this tree to dynamically load all child data
  setExpandAnim(string type) : void TreeView
Sets up the animation for expanding children
  toString() : string TreeView
TreeView instance toString

Public Events

Event Defined By
  animComplete : (YAHOO.widget.Node node) TreeView
When animation is enabled, this event fires when the animation completes
  animStart : (YAHOO.widget.Node node) TreeView
When animation is enabled, this event fires when the animation starts
  collapse : (YAHOO.widget.Node node) TreeView
Fires when a node is going to be expanded. Return false to stop the expand.
  expand : (YAHOO.widget.Node node) TreeView
Fires when a node is going to be collapsed. Return false to stop the collapse.

Property Details

id

public String id
The id of tree container element
This property is defined by TreeView.

locked

public boolean locked
We lock the tree control while waiting for the dynamic loader to return
This property is defined by TreeView.

maxAnim

public int maxAnim
The maximum number of animations to run at one time.
This property is defined by TreeView.

nodeCount<static>

public int nodeCount<static>
<static> Count of all nodes in all trees
This property is defined by TreeView.

Constructor Details

TreeView

public function TreeView(string|HTMLElement id)
Parameters:
  • id : string|HTMLElement
    The id of the element, or the element itself that the tree will be inserted into.

Method Details

addHandler<static>

public function addHandler<static>(el the, string sType, function fn)
<static> Add a DOM event
Parameters:
  • the : el
    elment to bind the handler to
  • sType : string
    the type of event handler
  • fn : function
    the callback to invoke
Returns:
  • void
This method is defined by TreeView.

animateCollapse

public function animateCollapse(el {HTMLElement}, node {YAHOO.util.Node})
Perform the collapse animation if configured, or just show the element if not configured or too many animations are in progress
Parameters:
  • {HTMLElement} : el
    the element to animate
  • {YAHOO.util.Node} : node
    the node that was expanded
Returns:
  • boolean
    true if animation could be invoked, false otherwise
This method is defined by TreeView.

animateExpand

public function animateExpand(el {HTMLElement}, node {YAHOO.util.Node})
Perform the expand animation if configured, or just show the element if not configured or too many animations are in progress
Parameters:
  • {HTMLElement} : el
    the element to animate
  • {YAHOO.util.Node} : node
    the node that was expanded
Returns:
  • boolean
    true if animation could be invoked, false otherwise
This method is defined by TreeView.

collapseAll

public function collapseAll()
Collapses all expanded child nodes in the entire tree.
Parameters:
  • None.
Returns:
  • void
This method is defined by TreeView.

collapseComplete

public function collapseComplete()
Function executed when the collapse animation completes
Parameters:
  • None.
Returns:
  • void
This method is defined by TreeView.

draw

public function draw()
Renders the tree boilerplate and visible nodes
Parameters:
  • None.
Returns:
  • void
This method is defined by TreeView.

expandAll

public function expandAll()
Expands all child nodes. 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.
Parameters:
  • None.
Returns:
  • void
This method is defined by TreeView.

expandComplete

public function expandComplete()
Function executed when the expand animation completes
Parameters:
  • None.
Returns:
  • void
This method is defined by TreeView.

getEl

public function getEl()
Returns the tree's host element
Parameters:
  • None.
Returns:
  • HTMLElement
    the host element
This method is defined by TreeView.

getNode<static>

public function getNode<static>(treeId {String}, nodeIndex {String})
<static> Global method for getting a node by its id. Used in the generated tree html.
Parameters:
  • {String} : treeId
    the id of the tree instance
  • {String} : nodeIndex
    the index of the node to return
Returns:
  • Node
    the node instance requested, null if not found
This method is defined by TreeView.

getNodeByIndex

public function 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 : int
    the index of the node wanted
Returns:
  • Node
    the node with index=nodeIndex, null if no match
This method is defined by TreeView.

getNodeByProperty

public function 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 : object
    the property to search (usually a string)
  • value : object
    the value we want to find (usuall an int or string)
Returns:
  • Node
    the matching node, null if no match
This method is defined by TreeView.

getNodesByProperty

public function 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 : object
    the property to search (usually a string)
  • value : object
    the value we want to find (usuall an int or string)
Returns:
  • Array
    the matching collection of nodes, null if no match
This method is defined by TreeView.

getRoot

public function getRoot()
Returns the root node of this tree
Parameters:
  • None.
Returns:
  • Node
    the root node
This method is defined by TreeView.

getTree<static>

public function getTree<static>(treeId {String})
<static> Global method for getting a tree by its id. Used in the generated tree html.
Parameters:
  • {String} : treeId
    the id of the tree instance
Returns:
  • TreeView
    the tree instance requested, null if not found.
This method is defined by TreeView.

onCollapse

public function onCollapse(node {Node})
Deprecated. Abstract method that is executed when a node is collapsed.
Parameters:
  • {Node} : node
    the node that was collapsed.
Returns:
  • void
This method is defined by TreeView.

onExpand

public function onExpand(node {Node})
Deprecated. Abstract method that is executed when a node is expanded
Parameters:
  • {Node} : node
    the node that was expanded
Returns:
  • void
This method is defined by TreeView.

popNode

public function popNode(Node the)
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
    node to remove
Returns:
  • void
This method is defined by TreeView.

preload<static>

public function preload<static>(string prefix)
<static> Attempts to preload the images defined in the styles used to draw the tree by rendering off-screen elements that use the styles.
Parameters:
  • prefix : string
    the prefix to use to generate the names of the images to preload, default is ygtv
Returns:
  • void
This method is defined by TreeView.

removeChildren

public function 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 : Node
    the node to purge
Returns:
  • void
This method is defined by TreeView.

removeHandler<static>

public function removeHandler<static>(el the, string sType, function fn)
<static> Remove a DOM event
Parameters:
  • the : el
    elment to bind the handler to
  • sType : string
    the type of event handler
  • fn : function
    the callback to invoke
Returns:
  • void
This method is defined by TreeView.

removeNode

public function removeNode(Node The, boolean autoRefresh)
Removes the node and its children, and optionally refreshes the branch of the tree that was affected.
Parameters:
  • The : Node
    node to remove
  • autoRefresh : boolean
    automatically refreshes branch if true
Returns:
  • boolean
    False is there was a problem, true otherwise.
This method is defined by TreeView.

setCollapseAnim

public function setCollapseAnim(string the)
Sets up the animation for collapsing children
Parameters:
  • the : string
    type of animation (acceptable values defined in YAHOO.widget.TVAnim)
Returns:
  • void
This method is defined by TreeView.

setDynamicLoad

public function setDynamicLoad(function fnDataLoader, iconMode {int})
Configures this tree to dynamically load all child data
Parameters:
  • fnDataLoader : function
    the function that will be called to get the data
  • {int} : iconMode
    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.
Returns:
  • void
This method is defined by TreeView.

setExpandAnim

public function setExpandAnim(string type)
Sets up the animation for expanding children
Parameters:
  • type : string
    the type of animation (acceptable values defined in YAHOO.widget.TVAnim)
Returns:
  • void
This method is defined by TreeView.

toString

public function toString()
TreeView instance toString
Parameters:
  • None.
Returns:
  • string
    string representation of the tree
This method is defined by TreeView.

Event Details

animComplete

public event animComplete
When animation is enabled, this event fires when the animation completes
Subscribers will be called with the following parameters:
  • node : YAHOO.widget.Node
    the node that is expanding/collapsing @parm {String} type the type of animation ("expand" or "collapse")
This event is defined by TreeView.

animStart

public event animStart
When animation is enabled, this event fires when the animation starts
Subscribers will be called with the following parameters:
  • node : YAHOO.widget.Node
    the node that is expanding/collapsing @parm {String} type the type of animation ("expand" or "collapse")
This event is defined by TreeView.

collapse

public event collapse
Fires when a node is going to be expanded. Return false to stop the expand.
Subscribers will be called with the following parameters:
  • node : YAHOO.widget.Node
    the node that is expanding/collapsing
This event is defined by TreeView.

expand

public event expand
Fires when a node is going to be collapsed. Return false to stop the collapse.
Subscribers will be called with the following parameters:
  • node : YAHOO.widget.Node
    the node that is expanding/collapsing
This event is defined by TreeView.

yui-ext - Copyright © 2006 Jack Slocum. | Yahoo! UI - Copyright © 2006 Yahoo! Inc.
All rights reserved.