Class YAHOO.widget.Node

Object
   |
   +--YAHOO.widget.Node
Direct Known Subclasses:
YAHOO.widget.TextNode, YAHOO.widget.HTMLNode, YAHOO.widget.RootNode

class YAHOO.widget.Node

Field Summary [top]

Node[] children
This node's child node collection. 
boolean childrenRendered
Flag that is set to true the first time this node's children are rendered. 
object data
The data linked to this node. 
function dataLoader
Function to execute when we need to get this node's child data. 
boolean expanded
The node's expanded/collapsed state 
boolean hasIcon
The toggle/branch icon will not show if this is set to false. 
string href
The href for the node's label. 
int index
The index for this instance obtained from global counter in YAHOO.widget.TreeView. 
boolean isLoading
This is true for dynamically loading nodes while waiting for the callback to return. 
boolean multiExpand
Can multiple children be expanded at once? 
Node nextSibling
This node's next sibling 
Node parent
Parent node 
Node previousSibling
This node's previous sibling 
boolean renderHidden
Should we render children for a collapsed node? 
string target
The label href target, defaults to current window 
TreeView tree
Tree instance this node is part of 

Constructor Summary [top]

YAHOO.widget.Node
The base class for all tree nodes. 

Method Summary [top]

void collapse ()
Hides this nodes children (creating them if necessary), changes the toggle style. 
void collapseAll ()
Recursively collapses all of this node's children. 
string completeRender ()
Called when we know we have all the child data. 
void expand ()
Shows this nodes children (creating them if necessary), changes the toggle style, and collapses its siblings if multiExpand is not set. 
void expandAll ()
Recursively expands all of this node's children. 
Node getAncestor (<int> depth)
Returns this node's ancestor at the specified depth. 
HTMLElement getChildrenEl ()
Returns the div that was generated for this node's children 
string getChildrenElId ()
Returns the id for this node's children div 
string getDepthStyle (<int> depth)
Returns the css class for the spacer at the specified depth for this node. 
HTMLElement getEl ()
Returns this node's container html element 
string getElId ()
Returns the id for this node's container div 
string getHoverStyle ()
Returns the hover style for the icon 
string getHtml ()
Returns the markup for this node and its children. 
Object getNodeHtml ()
Get the markup for the node. 
Object getSiblings ()
Returns a node array of this node's siblings, null if none. 
string getStyle ()
Returns the css style name for the toggle 
HTMLElement getToggleEl ()
Returns the element that is being used for this node's toggle. 
string getToggleElId ()
Returns the id for this node's toggle element 
string getToggleLink ()
Generates the link that will invoke this node's toggle method 
boolean hasChildren (checkForLazyLoad)
Checks if this node has children. 
void hideChildren ()
Hides this node's children 
void init (oData, oParent, expanded)
Initializes this node, gets some of the properties from the parent 
boolean isDynamic ()
Evaluates if this node's children should be loaded dynamically. 
boolean isRoot ()
Evaluates if this node is the root node of the tree 
void loadComplete ()
Load complete is the callback function we pass to the data provider in dynamic load situations. 
void setDynamicLoad (fnDataLoader)
Configures this node for dynamically obtaining the child data when the node is first expanded. 
void showChildren ()
Shows this node's children 
void toggle ()
Expands if node is collapsed, collapses otherwise. 

Field Detail [top]

children

Node[]   children
This node's child node collection.

childrenRendered

boolean   childrenRendered
Flag that is set to true the first time this node's children are rendered.

data

object   data
The data linked to this node. This can be any object or primitive value, and the data can be used in getNodeHtml().

dataLoader

function   dataLoader
Function to execute when we need to get this node's child data.

expanded

boolean   expanded
The node's expanded/collapsed state

hasIcon

boolean   hasIcon
The toggle/branch icon will not show if this is set to false. This could be useful if the implementer wants to have the child contain extra info about the parent, rather than an actual node.

href

string   href
The href for the node's label. If one is not specified, the href will be set so that it toggles the node.

index

int   index
The index for this instance obtained from global counter in YAHOO.widget.TreeView.

isLoading

boolean   isLoading
This is true for dynamically loading nodes while waiting for the callback to return.

multiExpand

boolean   multiExpand
Can multiple children be expanded at once?

nextSibling

Node   nextSibling
This node's next sibling

parent

Node   parent
Parent node

previousSibling

Node   previousSibling
This node's previous sibling

renderHidden

boolean   renderHidden
Should we render children for a collapsed node? It is possible that the implementer will want to render the hidden data...

target

string   target
The label href target, defaults to current window

tree

TreeView   tree
Tree instance this node is part of

Constructor Detail [top]

YAHOO.widget.Node

YAHOO.widget.Node ()
The base class for all tree nodes. The node's presentation and behavior in response to mouse events is handled in Node subclasses.
Parameters:
oData - {object} a string or object containing the data that will be used to render this node
oParent - {Node} this node's parent node
expanded - {boolean} the initial expanded/collapsed state

Method Detail [top]

collapse

void collapse ()
Hides this nodes children (creating them if necessary), changes the toggle style.

collapseAll

void collapseAll ()
Recursively collapses all of this node's children.

completeRender

string completeRender ()
Called when we know we have all the child data.
Returns:
children html

expand

void expand ()
Shows this nodes children (creating them if necessary), changes the toggle style, and collapses its siblings if multiExpand is not set.

expandAll

void expandAll ()
Recursively expands all of this node's children.

getAncestor

Node getAncestor (<int> depth)
Returns this node's ancestor at the specified depth.
Parameters:
depth - the depth of the ancestor.
Returns:
the ancestor

getChildrenEl

HTMLElement getChildrenEl ()
Returns the div that was generated for this node's children
Returns:
this node's children div

getChildrenElId

string getChildrenElId ()
Returns the id for this node's children div
Returns:
the element id for this node's children div

getDepthStyle

string getDepthStyle (<int> depth)
Returns the css class for the spacer at the specified depth for this node. If this node's ancestor at the specified depth has a next sibling the presentation is different than if it does not have a next sibling
Parameters:
depth - the depth of the ancestor.
Returns:
the css class for the spacer

getEl

HTMLElement getEl ()
Returns this node's container html element
Returns:
the container html element

getElId

string getElId ()
Returns the id for this node's container div
Returns:
the element id

getHoverStyle

string getHoverStyle ()
Returns the hover style for the icon
Returns:
the css class hover state

getHtml

string getHtml ()
Returns the markup for this node and its children.
Returns:
the markup for this node and its expanded children.

getNodeHtml

Object getNodeHtml ()
Get the markup for the node. This is designed to be overrided so that we can support different types of nodes.
Returns:
The HTML that will render this node.

getSiblings

Object getSiblings ()
Returns a node array of this node's siblings, null if none.
Returns:
Node[]

getStyle

string getStyle ()
Returns the css style name for the toggle
Returns:
the css class for this node's toggle

getToggleEl

HTMLElement getToggleEl ()
Returns the element that is being used for this node's toggle.
Returns:
this node's toggel html element

getToggleElId

string getToggleElId ()
Returns the id for this node's toggle element
Returns:
the toggel element id

getToggleLink

string getToggleLink ()
Generates the link that will invoke this node's toggle method
Returns:
the javascript url for toggling this node

hasChildren

boolean hasChildren (checkForLazyLoad)
Checks if this node has children. If this node is lazy-loading and the children have not been rendered, we do not know whether or not there are actual children. In most cases, we need to assume that there are children (for instance, the toggle needs to show the expandable presentation state). In other times we want to know if there are rendered children. For the latter, "checkForLazyLoad" should be false.
Parameters:
checkForLazyLoad - {boolean} should we check for unloaded children?
Returns:
true if this has children or if it might and we are checking for this condition.

hideChildren

void hideChildren ()
Hides this node's children

init

void init (oData, oParent, expanded)
Initializes this node, gets some of the properties from the parent
Parameters:
oData - {object} a string or object containing the data that will be used to render this node
oParent - {Node} this node's parent node
expanded - {boolean} the initial expanded/collapsed state

isDynamic

boolean isDynamic ()
Evaluates if this node's children should be loaded dynamically. Looks for the property both in this instance and the root node. If the tree is defined to load all children dynamically, the data callback function is defined in the root node
Returns:
true if this node's children are to be loaded dynamically

isRoot

boolean isRoot ()
Evaluates if this node is the root node of the tree
Returns:
true if this is the root node

loadComplete

void loadComplete ()
Load complete is the callback function we pass to the data provider in dynamic load situations.

setDynamicLoad

void setDynamicLoad (fnDataLoader)
Configures this node for dynamically obtaining the child data when the node is first expanded.
Parameters:
fmDataLoader - {function} the function that will be used to get the data.

showChildren

void showChildren ()
Shows this node's children

toggle

void toggle ()
Expands if node is collapsed, collapses otherwise.