These are the functions supported by the LiknoTreeRoot object. The return type of each function, if any, is indicated underneath each function name. If the returned variable is restricted to specific values, those will be indicated in brackets next to the return type.
Adds a context (right-click) menu to the items in the tree. The context menu will inherit the styles used by the tree by default.
Compares two leaves, based on this tree's sortOnData and sortAscending properties (if -1, a lexicographical comparison is performed).
Creates the CSS <style> tag with the classes to be used by the tree. Most of the time you will not need to call this function directly, since it is called by drawTree if cssCreated is false.
Parameters |
# |
name |
type |
description |
1 |
leaf |
LiknoTreeElement |
The node we want to delete. |
Deletes a node and all its children (recursively) from the tree.
drawTree
Writes the HTML code which draws the tree on your webpage. If cssCreated is false (which is by default the first time the tree is drawn), it will also create the necessary CSS style sheet for the classes used by your tree.
getLeafById
Parameters |
# |
name |
type |
description |
1 |
leaf |
string |
Specifies the name of this class to be used internally by the tree. Note that this will not be the name by which you can refer to this class in the rest of your HTML document. |
2 |
leafid |
string |
Specifies the set of CSS styles comprising this class. |
Searches under leaf for a node with iid = leafid and returns it if found, otherwise returns null.
loadTreeState
Loads the tree state (expanded/collapsed branches) from the associated cookie (if any). Returns false if no cookie was found.
saveTreeState
Saves the tree state (expanded/collapsed branches) in a cookie for persistence between sessions. You will probably want to call this function when the user leaves your webpage (in your onunload event handler).
selectBranch
Parameters |
# |
name |
type |
description |
1 |
branchid |
string |
Specifies the iid of the branch on which the action will be performed. |
Selects the branch specified by branchid. For more information also check on the iid format.
The following examples assume your tree is named "myTree":
- select the second main item myTree.selectBranch("myTree_1");
- select the third sub item of the first main item myTree.selectBranch("myTree_0_2");
sortBranchId
Parameters |
# |
name |
type |
description |
1 |
branchid |
string |
Specifies the iid of the branch on which the action will be performed. |
2 |
onData |
number |
A valid index in the data array or -1. |
3 |
recursively |
boolean |
Indicates whether sorting will be performed on all children of this branch recursively. |
4 |
ascending |
boolean |
Indicates the sorting order. |
Sorts the children of the branch specified by branchid recursively if recursively is true. If onData is a valid index in the array of associated data, sorting is performed using these values, otherwise a lexicographical sorting on the content of the nodes is performed.
The onData and ascending values set the sortOnData and sortAscending properties of this tree.
toggleBranch
Parameters |
# |
name |
type |
description |
1 |
branchid |
string |
Specifies the iid of the branch on which the action will be performed. |
Toggles the expanded/collapsed state of the branch specified by branchid.