class SAPO.Component.TreeView
 Creates a tree view - branches can be opened/closed; nodes can be selected
 It can be populated two ways:
 - pass on UL with LI/UL/... recursive structure
 - pass on empty UL and Array of Strings/Arrays in options.values

 requires SAPO.Dom.Css
 requires SAPO.Dom.Element
 requires SAPO.Dom.Event
 
Authors:
jose.p.dias AT co.sapo.pt
Version:
1.1
Since:
October 2011
Defined in Component/TreeView/1.1/lib.js

Constructor Summary
TreeView (String|DomElement element, Object options)
returns a new instance of SAPO.Component.TreeView

Function Summary
clears the selected node (if any)
removes any dependecies
returns the selected note's text
returns the Array of the selected path (from root to selected node)
returns array of toggled ids
render()
renders any additional DOM/CSS content
selectNode (id|SpanElement content)
changes node selection (if not found or undefined selects nothing)
sets toggled nodes
changes the state of all nodes in the tree
toggleSubTree (String|String[] idOrIds)
toggles sub tree(s)

Constructor Details

constructor TreeView

TreeView(String|DomElement element, Object options)
returns a new instance of SAPO.Component.TreeView
Parameters:
element - element which will be enriched (or its id)
options - optional object to pass on options
  • [ Array values ] - array of string with elements to populate
  • [ Function onSelectionChanged ] - invoked internally when the selection changes
  • [ String cssURI ] - pass on alternate URI if you want to override the default CSS

Function Details

function clearSelection

clearSelection()
clears the selected node (if any)

function destroy

destroy()
removes any dependecies

function getSelectedNode

String getSelectedNode()
returns the selected note's text
Returns:
the selected text or undefined, if nothing is selected

function getSelectedPath

String[] getSelectedPath()
returns the Array of the selected path (from root to selected node)
Returns:
the selected text or undefined, if nothing is selected

function getToggledNodes

String[] getToggledNodes()
returns array of toggled ids

function render

render()
renders any additional DOM/CSS content

function selectNode

selectNode(id|SpanElement content)
changes node selection (if not found or undefined selects nothing)
Parameters:
content - node content to look for (either String or SPAN)

function setToggledNodes

setToggledNodes(String[] ids)
sets toggled nodes
Parameters:
ids

function toggleNodesOpening

toggleNodesOpening()
changes the state of all nodes in the tree

function toggleSubTree

toggleSubTree(String|String[] idOrIds)
toggles sub tree(s)
Parameters:
idOrIds