Public Member Functions | |
__construct () | |
Creates a new tree. | |
addItemsTo ($parent) | |
Sets the current parent node. | |
getParentNode () | |
Retrieves the current parent node. | |
setItemState ($item, $collapsed, $rec=false) | |
Sets the collapsed/expanded state of a node and optionally its children. |
A tree consists of a set of nodes, which may have children, which may themselves have children. Each node can be expanded or collapsed by clicking on the +/- icon next to it. If a node is collapsed, then all its children are hidden. If it is expanded, then the immediate children become visible again. To create a tree, simply use the standard add()
syntax. In order to create a hierarchy, however, you must tell the tree to which node you are adding child nodes. There are several ways to do this. One way is to call addItemsTo()() and specify a node to add child nodes to. Another way is to explicitly specify the parent node when adding, like so: $tree->addLabel("Foo", array('parent' => $someNode))
. You can also request that a newly added node become the new default parent by using the asParent
parameter, like so: $tree->addLabel("Bar", array('asParent' => true))
.
There are a number of CSS classes used by trees. Each item has a class, which refers specifically to the list item and not its children or its expand/collapse button. There are also several classes for the bullets (the expand/collapse buttons). The property 'bullet_class' is combined with one of 'bullet_none_class' (for nodes with no children), or 'bullet_collapse_class' (for nodes with expanded children) or 'bullet_expand_class' (for nodes with collapsed children). And finally, 'inner_class' specifies the appearance of an entire subtree, which is represented by HTML <UL>
The TKHTML for a tree is simple. Each component contained with the tree XML will be added to the tree. To specify subtrees, put the nodes to be in the subtree inside a <subtree>...</subtree>
block. The subtree's parent is the component that is present right before the subtree tag. You can nest subtrees as many times as you like. You can specify whether nodes are collapsed or not using the collapsed
attribute, and setting it to one of the following four values:
self:false
- this node is NOT collapsed self:true
- this node is collapsed (children not visible) children:false
- this node is NOT collapsed and make all children not collapsed as well children:true
- this node is collapsed and all its children are collapsed as well, although they are initially not visible
array
: CSS class for a node (HTML <LI>) array
: CSS style for a node array
: CSS class for a subtree (HTML <UL>) array
: CSS style for a subtree array
: CSS class combined with bullet_class
for a node with no children array
: CSS class combined with bullet_class
for a node with visible children array
: CSS class combined with bullet_class
for a node with hidden children
TKTree::addItemsTo | ( | $ | parent | ) |
Sets the current parent node.
Subsequent add operations will add children to this node. If the node is null, then new nodes will be added to the root of the tree.
$parent | [TKComponent]: new parent node or null for the root |
TKTree::getParentNode | ( | ) |
Retrieves the current parent node.
TKTree::setItemState | ( | $ | item, | |
$ | collapsed, | |||
$ | rec = false | |||
) |
Sets the collapsed/expanded state of a node and optionally its children.
A node is expanded if all its children are visible, and it is collapsed if they are not.
$item | [TKComponent]: which node to change state | |
$collapsed | [boolean]: true if node should be collapsed, false for expanded | |
$rec | [boolean]: whether to apply this new state to subchildren |