Main features
Multibrowser/Multiplatform support
Full controll with JavaScript
Dynamic loading
XML support
Dynamic rendering (Smart XML parsing) for big trees
drag-&-drop (within one tree, between trees, between frames)
checkboxes (two/three states)
customizable icons (with javascript or xml)
context menu (integration with dhtmlxMenu)
user data for nodes
multi-line tree items
high stability
Macromedia Cold Fusion support
Supported browsers
IE 5.x and above
Mac OS X Safari
Mozilla 1.4 and above
FireFox 0.9 and above
Opera (Xml loading depends on browser version)
Working with dhtmlXTree
Initialize object on page
Parameters passed to the constructor are:
object to attach tree to (should be loaded before calling constructor)
width of the tree
height of the tree
identifier of level parent to tree root level
Specify Additional parameters of the tree:
setImagePath(url) - method specifies the path to the folder with tree icons
enableCheckBoxes(mode) - enable/disable checkboxes in tree (checkboxes appear by default)
Set Event Handlers
Selected node ID will be passed to function specified as argument for setDefaultAction(funcObj)
Dropped node ID and new parent node ID will be passed to function specified as argument for setDragFunction(funcObj)
node ID and node state will be passed to the function specified as argument for setOpenAction(funcObj,state)
node ID will be passed to the function specified as argument for setDblClickAction(funcObj)
Adding nodes with Script
0s passed to the function for arguments 4-7 (function to call on select, images) mean use default values for them
Last argument is a comma delimited string of following possible value (upper case only):
SELECT - move selection to this node after inserting
CALL - call function on select
TOP - add node to the top position
CHILD - node has children
CHECKED - checkbox is checked (if exists)
Loading data with XML
ID of opened node (as id url parameter) will be added to URL specified in initXMLAutoLoading(url) during the call
No additional ID is added to the url specified in loadXML(url) method during the call
Using loadXML() without parameters you load url specified in initXMLAutoLoading(url) method
XML Syntax:
-
true
<tree> node is mandatory. It specifies the parent of loading block of data. According to this its id parameter specifies the ID oth that parent.
To load root level you need to specify the ID you used when created tree object: new myObjTree(boxObject,width,height,0)
<item> can contain subitems (in order to load more than one level at once) or not.
Mandatory parameters for this tag are:
text - label of the node
id - id of the node
Optional parameters for this tag are:
im0 - image for node without children (tree will get images from the path specified in setImagePath(url) method)
im1 - image for opened node with children
im2 - image for closed node with children
select - select node on load (0/1)
open - show node opened (0/1)
call - call function on select(0/1)
checked - check checkbox if exists(0/1)
child - spec. if node has children (1) or not (0)
To set userdata directly within XML use <userdata>
It has just one parameter:
name
and value to specify userdata value
Setting custom icons to nodes
There are two ways to set custom icons for the node. And it depends on the way you add items.
Important: tree will get images for the nodes from the path specified in setImagePath(url) method.
Javascript way. Using arguments of insertNewChild(...) or insertNewNext(...) methods:
XML way. Using parameters of <item> tag:
-
im0 - image for node without children (tree will get images from the path specified in setImagePath(url) method)
im1 - image for opened node with children
im2 - image for closed node with children
Building dynamic tree
If your tree should contain large amount of nodes (or you simply do not want to waist time loading hidden nodes), it would be better to load them on demand, not at once.
For this purpose we made the tree to load levels dynamically using XML.
See chapter "Loading data with XML"
Manipulating nodes
A few examples of manipulating node with tree object methods:
Cold Fusion Tag for dhtmlXTree
...configuration xml...
name - [optional] name of the tree js object to use in javascript, if skiped, then name autogenerated
width - [optional] width of the tree (definitely it sets the with of the tree box, leaving the with of the tree itself by 100%)
height - [optional] height of the tree
JSPath - [optional] absolute or relative path to directory which contains tree js files, "js" directory by default
CSSPath - [optional] absolute or relative path to directory which contains tree css files, "css" directory by default
iconspath - [optional] absolute or relative path to directory which contains tree icon files, "img" directory by default
xmldoc - [mandatory for xml loading] url of the xml file used to load levels dynamically
checkboxes - [optional] show checkboxes (none, twoState, threeState)
dragndrop - [optional] activate drag-&-drop (true,false)
style - [optional] style for the tree box
onSelect - [optional] javascript function to call on node selection
oncheck - [optional] javascript function to call on node (un)checking
onDrop - [optional] javascript function to call on node drop
im1 - [optional] default image used for child nodes
im2 - [optional] default image used for opened branches
im3 - [optional] default image used for closed branches
For description of optional configuration xml - see chapter "Loading data with XML"
Minimal possible tag syntax with on-page xml:
-
Minimal possible tag syntax with server-side xml:
With images specified:
-
-
-
With Events Handlers,Checkboxes and Drag-n-drop:
-
-
-