JSCookTree not only draws trees, but also provides a set of functions that further manipulate
the trees generated. This page describes them in detail. It does require some knowledge of
JavaScript to use them.
Function |
Description |
ctDraw (id, tree, themeProperty, themePrefix, branchControl, defaultExpandLevel)
|
Parameters
id
It is the id of the HTML element that would be used to contain the tree.
tree
It is the menu tree of what user is intended to display.
themeProperty
themePrefix
branchControl
- 0: no branch control.
- 1: only one branch is shown for the current tree.
- 2: only one branch is shown for the all the trees with branch control 2.
defaultExpandLevel
All tree nodes below defaultExpandLevel are always fully expanded.
Returns
treeIndex
It is the index of the tree being created.
This function draws the tree.
|
ctCollapseTree (id)
|
Parameters
id
It is the id of the HTML element that contains the tree.
Returns
- none
This function collapses the tree.
|
ctExpandTree (id, expandLevel)
|
Parameters
id
It is the id of the HTML element that contains the tree.
expandLevel
Up to expandLevel of tree nodes are expanded. The nodes
can be collapsed later.
Returns
- none
This function expands the tree. It does not work with branch control.
|
ctExposeItem (treeIndex, link)
|
Parameters
treeIndex
It is returned by ctDraw function.
link
It is the third field of a tree node.
Returns
treeItem
It is the table row of where the tree item is located.
This function expands the tree so that the item specified by the user
is exposed and selected. Tree branch control will take effect if the
tree uses it.
|
ctExposeTreeIndex (treeIndex, itemIndex)
|
Parameters
treeIndex
It is returned by ctDraw function.
itemIndex
It specifies the item index in the tree. The count
starts from 0.
Returns
treeItem
It is the table row of where the tree item is located.
This function expands the tree so that the item specified by the user
using itemIndex is exposed. Tree branch control will take effect if the
tree uses it. This function is similar to ctExposeItem ,
just used the itemIndex instead of its link to locate the item.
|
ctGetSelectedItem (treeIndex)
|
Parameters
treeIndex
It is returned by ctDraw function.
Returns
treeItem
It is the table row of where the tree item is located.
null if nothing is selected.
This function returns the treeItem object that is been selected for
the tree. For trees that use global branch control, this function
returns the global item that is selected.
|
ctMarkItem (treeIndex, link)
|
Parameters
treeIndex
It is returned by ctDraw function.
link
It is the third field of a tree node.
Returns
treeItem
It is the table row of where the tree item is located.
This function only change the item's id to JSCookTreeMarked .
It will not work for folder items. The purpose of function is to change
the style of the item.
|
ctMarkTreeIndex (treeIndex, itemIndex)
|
Parameters
treeIndex
It is returned by ctDraw function.
itemIndex
It specifies the item index in the tree. The count
starts from 0.
Returns
treeItem
It is the table row of where the tree item is located.
This function is similar to ctMarkItem and just used the
itemIndex instead of its link to locate the item.
|
ctOpenFolder (treeItem)
|
Parameters
treeItem
It is the table row where the tree item is located.
Returns
- none
This function expand the tree node at treeItem.
You can obtain treeItem by calling ctExposeItem or ctExposeTreeIndex .
|
ctCloseFolder (treeItem)
|
Parameters
treeItem
It is the table row where the tree item is located.
Returns
- none
This function collapse the tree node at treeItem.
You can obtain treeItem by calling ctExposeItem or ctExposeTreeIndex .
|