## dhtmlXTree Guide and Samples

### 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
- JSP support
- ASP.NET 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

    <div id="treeBox" style="width:200;height:200"></div>
    <script>
    	tree=new dhtmlXTreeObject(document.getElementById('treeBox'),"100%","100%",0);
    	tree.setImagePath("gfx/");
    	tree.enableCheckBoxes(false);
    	tree.enableDragAndDrop(true);
    </script>

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 (superroot)
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)
- enableDragAndDrop(mode) - enable/disable drag-n-drop in tree

#### Set Event Handlers

    <div id="treeBox" style="width:200;height:200"></div>
    <script>
    	tree=new dhtmlXTreeObject(document.getElementById('treeBox'),"100%","100%",0);
    	...
    	tree.setOnClickHandler(onNodeSelect);//set function object to call on node select
    	//see other available event handlers in API documentation
    	function onNodeSelect(nodeId){
    		...
    	}
    </script>

In most cases functions specified inside event handlers get some values with the arguments. For details about passed arguments please refer to API documentation.

#### Adding nodes with Script

    <script>
    	tree=new dhtmlXTreeObject('treeBox',"100%","100%",0);
    	...
    	tree.insertNewChild(0,1,"New Node 1",0,0,0,0,"SELECT,CALL,TOP,CHILD,CHECKED");
    	tree.insertNewNext(1,2,"New Node 2",0,0,0,0,"CHILD,CHECKED");
    </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

    <script>
    	tree=new dhtmlXTreeObject('treeBox',"100%","100%",0);
    	tree.setXMLAutoLoading("http://127.0.0.1/xml/tree.xml");
    	tree.loadXML("http://127.0.0.1/xml/tree.xml");//load root level from xml
    </script>

- 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:
    <?xml version='1.0' encoding='iso-8859-1'?>
    <tree id="0">
    	<item text="My Computer" id="1" child="1" im0="my_cmp.gif" im1="my_cmp.gif" im2="my_cmp.gif" call="true" select="yes">
    		<userdata name="system">true</userdata>
    		<item text="Floppy (A:)" id="11" child="0"  im0="flop.gif" im1="flop.gif" im2="flop.gif"/>
    		<item text="Local Disk (C:)" id="12" child="0"  im0="drv.gif" im1="drv.gif" im2="drv.gif"/>
    	</item>
    	<item text="Recycle Bin" id="4" child="0" im0="recyc.gif" im1="recyc.gif" im2="recyc.gif"/>
    </tree>

In PHP script use the following code for page header:

    <?php
    	if ( stristr($_SERVER["HTTP_ACCEPT"],"application/xhtml+xml") ) {
      		header("Content-type: application/xhtml+xml"); } else {
      		header("Content-type: text/xml");
    	}
    	echo("<?xml version=\"1.0\" encoding=\"iso-8859-1\"?>\n");
    ?>

<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. It also can contain <itemtext> tag, which can be used to add some HTML to item label (attribute text should be skipped then):

    <item id="123">
    	<itemtext><![CDATA[<font color="red">Label</font>]]></itemtext>
    </item>

Mandatory parameters for this tag are:
- text - label of the node
- id - id of the node
Optional parameters for this tag are:
- tooltip - tooltip for the node
- 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
- aCol - colour of not selected item
- sCol - colour of selected item
- select - select node on load (any value)
- style - node text style
- open - show node opened (any value)
- call - call function on select(any value)
- checked - check checkbox if exists(any value)
- child - spec. if node has children (1) or not (0)
- imheight - height of the icon
- imwidth - width of the icon
- topoffset - offset of the item from the node above
- radio - if non empty, then children of this node will have radiobuttons
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:

    <script>
    	var im0 = "doc.gif";//icon to show if node contains no children
    	var im1 = "opened.gif";//if node contains children and opened
    	var im2 = "closed.gif";//if node contains children and closed
    	tree.insertNewItem(0,1,"New Node 1",0,im0,im1,im2);
    	tree.insertNewNext(1,2,"New Node 2",0,"txt.gif","opened.gif","closed.gif");
    </script>

XML way. Using parameters of <item> tag:

    <?xml version='1.0' encoding='iso-8859-1'?>
    <tree id="0">
    	<item text="My Computer" id="1" child="1" im0="doc.gif" im1="my_opened.gif" im2="my_closed.gif">
    </tree>

- 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"
or for more details "Dynamical Loading in dhtmlxTree v.1.x" article from our Knowledge Base.

#### Manipulating nodes

A few examples of manipulating node with tree object methods:

    <script>
    	tree=new dhtmlXTreeObject('treeboxbox_tree',"100%","100%",0);
    	...
    	var sID = tree.getSelectedItemId();//get id of selected node
    	tree.setLabel(sID,"New Label");//change label of selecte node
    	tree.setItemColor(sID,'blue','red');//set colors for selected node's label (for not selected state and for selected state)
    	tree.openItem(sID);//expand selected node
    	tree.closeItem(sID);//close selected node
    	tree.changeItemId(sID,100);//change id of selected node to 100
    	alert("This node has children: "+tree.hasChildren(100));//show alert with information if this node has children
    </script>

#### Serializing Tree

Serialization methods allows getting tree in xml representation (xml string). Various levels of serializations define the number of tree parameters reflected in resulting XML:

    <script>
    	tree.setSerializationLevel(userDataFl,itemDetailsFl);
    	var myXmlStr = tree.serializeTree();

    </script>

- no parameters - id,open,select,text,child
- userDataFl true - userdata
- itemDetailsFl true - im0,im1,im2,acolor,scolor,checked,open

#### Tooltips

There are three ways to set tooltip for the node:
- Use node label ("text" attribute of item node) as tooltip - enableAutoTooltips(mode) - false by default
- Use "tooltip" attribute of item node for tooltip (it is used by default if this attribute was specified)
- setItemText(itemId,newLabel,newTooltip)

#### Moving Nodes

To move Item programaticaly developer can use the following ways:
To move upp/down/left:

    	tree.moveItem(nodeId,mode)

mode possible values are:
- "down" - move node down in list of nodes (do not pay attention on hierarchy)
- "up" - move node up in list of nodes
- "left" - move node up in hierarchy
To move directly into position (within tree)

    	tree.moveItem(nodeId,mode,targetId)

mode possible values are:
- "item_child" - place node as child of node specified in third argument
- "item_sibling" - place node as sibling of node specified in third argument
targetId - id of target node.
To move node into position (to another tree)

    	tree.moveItem(nodeId,mode,targetId,targetTree)

mode possible values as above.
targetId - id of target node (in target tree).
targetTree - target tree object
Cut/Paste way
Another way is to use doCut(),doPaste(id) - but this works with selected item only. Developer can also delete node in one place and create it in other (also the way ;-)).
To give users the possibility to move items use drag-n-drop functionlity.

#### Items Counter

There is a possibility to display item children elements counter with the label of the node. To activate this feature use the following:

    <script>
    	tree.setChildCalcMode(mode);
    </script>

Possible modes are:
- "child" - all childs on this level
- "leafs" - all childs without subchilds on this level
- "childrec" - all childs
- "leafsrec" all childs without subchilds
- "disabled" - nothing
Other related methods:
_getChildCounterValue(itemId) - get current counter value
setChildCalcHTML(before,after) - html around counter to change default [x]
Use child attribute in xml if you need to set counter value when using dynamical loading.

#### Smart XML Parsing

The idea of Smart XML Parsing is simple - the entire tree structute loaded on client side, but only nodes which should be displayed are rendered. This helps to dramaticaly decrease loading time and general performance of large trees. Plus - in the contrary to Dynamical Loading - entrire tree structure is available for most of script methods (for example Search performed agains all nodes - not only rendered). To activate Smart XML Parsing use the following method:

    <script>
    	tree.enableSmartXMLParsing(true);//false to disable
    </script>

Smart XML Parsing do not work if tree loaded fully expanded.

#### Checkboxes in tree

dhtmlxTree support two or three state checkboxes. Three state checkboxes means: checked/unchecked/some-child-checked (not all). To enable three state checkboxes use the following method:

    <script>
    	tree.enableThreeStateCheckboxes(true)//false to disable
    </script>

Using three-state checboxes with smart xml parsing you need to specify third state manually (checked="-1"):

    	<item checked="-1" ...>
    		<item checked="1" .../>
    		<item .../>
    	</item>

Checkboxes can be disabled - disableCheckbox(id,state)
Some node can hide checkboxes - showItemCheckbox(id,state) (nocheckbox xml attribute)
Since v.1.4 showItemCheckbox can be aplied to whole tree (use 0 or null as first argument)

#### Radiobuttons in tree

dhtmlxTree support radiobuttons. To turn them on for the whole tree

    <script>
    	tree.enableRadiobuttons(true);
    </script>

To turn on radiobuttons for some particular node (instead of checkboxes):

    <script>
    	tree.enableCheckboxes(true);
    	tree.enableRadiobuttons(nodeId,true);
    </script>

By default radibuttons grouped by level, but since v.1.4 it can be set to whole tree:

    	tree.enableRadiobuttons(true)

Checkboxes related API methods and XML attributes are actual for radiobuttons also (taking into account specificity of radiobuttons functionlity).

#### Drag-and-drop technics

There are three modes of drag-n-drop (set with setDragBehavior(mode)):
- Drop as child - "child"
- Drop as sibling - "sibling"
- Complex mode (both previous are active) - "complex"
Plus two modes of each of them:
- 1. Common drag-n-drop
- 2. Copy with drag-n-drop - tree.enableMercyDrag(1/0)
All modes can be changed on the fly.

##### Event handlers

To process drag-n-drop before drop occured use onDrug event handler - setDragHandler(func). If func doesn't return true, drop will be canceled.
After drop occured there is another event - onDrop - handle it using setDropHandler(func).
Both event handlers pass 5 parameters into the func object:
- id of node which was dragged
- id of target node
- id of target-before node (if drop as sibling)
- tree object source
- tree object target

#### Drag-and-drop between iframes

Drag-n-drop between iframes enabled by default. All you need to do additionaly is to insert the following code into the page where no tree exists:

    <script src="js/dhtmlXCommon.js"></script>
    <script>
    	new dhtmlDragAndDropObject();
    </script>

#### Increasing Performance

Taking into account the general low performance of DHTML we introducrd two ways of increasing performance of large trees:
1. Dynamical Loading
2. Smart XML Parsing
3. Distributed Parsing
Also be sure your tree was organized well - putting a lot of items on one level of the branch makes tree difficalt for visual perception and decrease performance, although Distributed Parsing can help here.

#### Context Menu

There is built in context menu in dhtmlxTree. The content of this menu can be set with XML or script. For changing context menu content depending on tree item developer can implement function for hidding/showing items of the same menu or associate different menues with different items. To enable context menu do the following:

    <script>
    //init menu
    		aMenu=new dhtmlXContextMenuObject('120',0,"Demo menu");
    		aMenu.menu.setGfxPath("../imgs/");
    		aMenu.menu.loadXML("menu/_context.xml");
    		aMenu.setContextMenuHandler(onMenuClick);

    //init tree
    		tree=new dhtmlXTreeObject("treeboxbox_tree","100%","100%",0);
    		...
    		tree.enableContextMenu(aMenu); //link context menu to tree
    function onMenuClick(id){
    	alert("Menu item "+id+" was clicked");
    }
    </script>

HTTPS compatibility
For HTTPS compatibility we added two more parameters to context menu constructor:
- Images URL
- Dummy page URL (url of the page to use for iframes src /now they are empty as iframes are used to make menu be positioned under selectboxes in IE/ in menu to make it compatible with https)

      <script>
      //init menu compatible with sHTML
      	aMenu=new dhtmlXContextMenuObject('120',0,"Demo menu","imgs/","empty.html");
      	...
      </script>

#### Refreshing nodes

- refreshItems(itemIdList,source) to refresh only items from the itemIdList (not their children)
- refreshItem(itemId) - to refresh children of item with itemId. In this case auto loading should be activated.

#### Sorting nodes

You can sort nodes in dhtmlxTree Pro (necessary file: dhtmlXTree_sb.js) using follwoing ways:
Sort by label text (if no custom comparator specified)

    	tree.sortTree(nodeId,order,all_levels);

- nodeId - parent of the level to start sorting from (id of superroot for entire tree)
- order - sort direction: "ASC"/"DES"
- all_levels - if true, then all sublevels will be processed as well
Custom defined sorting

    	//define your comparator (in our case it compares second words in label)
    	function mySortFunc(idA,idB){
    		a=(tree.getItemText(idA)).split(" ")[1]||"";
    		b=(tree.getItemText(idB)).split(" ")[1]||"";
    		return ((a>b)?1:-1);
    	}
    	tree = new ...
    	//attach your comparator to the tree
    	tree.setCustomSortFunction(mySortFunc);

Comparator function gets 2 nodes IDs. Use your tree object there and these IDs to return a comparison result.
If custome comparator was specified, then tree.sortTree(...) method uses it for sorting.

#### Search functionlity

Search functionality of dhtmlxTree allows moving focus on node with label fitting searchString mask.
Has support for Smart XML Parsing.
Script syntax:

    	tree.findItem(searchString); //find item next to current selection
    	tree.findItem(searchString,1,1)//find item previous to current selection
    	tree.findItem(searchString,0,1)//search from top

Example of usage is included in Professional Edition package – samples/treeExPro2.html.

#### Multiline tree items

...allows displaying tree items in multiline mode. For now it is recommended to turn tree lines off for better appearance. To enable multiline feature you need to do the following:

    	tree.enableTreeLines(false);
    	tree.enableMultiLineItems(true);

Example of usage is included in professional edition package – samples/treeExPro6.html.

#### Icons in Tree

#### Set Icons

There is a way to set icons for the node explicetly using script (setItemImage,setItemImage2) or xml (im0,im1,im2 attributes of item node):
- im0 - item without children
- im1 - closed item with children
- im2 - opened item with children

#### Set Icon Size

There is a way to set icon size for the whole tree or each node using script or xml:
XML syntax for icon size per each item (optional):

    <item ... imheight="Xpx" imwidth="Xpx"></item>

Script syntax:

    	tree.setIconSize(w,h);//set global icon size
    	tree.setIconSize(w,h,itemId)//set icon size for particular item

#### Keyboard Navigation

By default dhtmlxTree doesn't have keyboard support, but you can add dhtmlxTree_kn.js file to you page and enable keyboard support with just one javascript command:

    <script  src="../js/dhtmlXTree_kn.js"></script>
    <script>
    	tree.enableKeyboardNavigation(true);
    </script>

Default keys are:
- Up arrow - select upper item
- Down arrow - select lower item
- Right arrow - open item
- Left arrow - close item
- Enter - call item's action
But you also can assign your own keys for these:

    	tree.assignKeys([["up",104],["down",98],["open",102],["close",100],["call",101]]);

where "up"/"down"/"open"/"close"/"call" are available actions and numbers are key codes.

#### Distrebuted Parsing

Another way to increase big tree performance which has some levels with more than 100-200 nodes per level was introdused in v.1.3 of dhtmlxTree Professional Edition. This is Distrebuted Parsing. The main advantage is that you get the level visible and ready to utilization before it completely parsed.
To enable this functionlity use the following js command:

    <script>
    	tree.enableDistributedParsing(mode,count,timeout);
    </script>

Parameters are:
- mode - mandatory - true/false - enable/disable Distrebuted Parsing
- count - optional - number of nodes in portion
- timeout - optional - delay in milliseconds between portions
This functionaity is fully compatible with Smart XML Parsing

#### Error handling in dhtmlxTree

Some exceptions in dhtmlxTree can be captured and processed.

    function myErrorHandler(type, desc, erData){
    	alert(erData[0].status)
    }
    dhtmlxError.catchError("ALL",myErrorHandler);

Supported Error Types are:
- "All"
- "LoadXML"
Handler gets the following params:
- type - string (mentioned above)
- desc - error description (hardcoded in code)
- erData - error related array objects(see below).

Type | Object(s)
LoadXML | [0] - response object

### Cold Fusion Tag for dhtmlXTree

    <cf_dhtmlXTree
    	name="tree"
    	width="250"
    	height="250"
    	JSPath="../"
    	CSSPath="../"
    	iconspath="gfx/"
    	xmldoc="tree.xml"
    	checkboxes="false"
    	dragndrop="true"
    	style="background-color:whitesmoke;border:1px solid blue;"
    	onSelect="onNodeSelect"
    	onDrop="onDropNode">
    		...configuration xml...
    	</cf_dhtmlXTree>

- 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:

    <cf_dhtmlXTree>
    	<item text="Top node" id="t1" >
    		<item text="Child node 1" id="c1" ></item>
    		<item text="Child node 2" id="c2" ></item>
    	</item>
    </cf_dhtmlXTree>

Minimal possible tag syntax with server-side xml:

    <cf_dhtmlXTree 	xmldoc="tree.xml">
    </cf_dhtmlXTree>

With images specified:

    <cf_dhtmlXTree
    	im1="book.gif"
    	im2="books_open.gif"
    	im3="books_close.gif">
    	<item text="Mystery " id="mystery"  open="yes" >
    		<item text="Lawrence Block" id="lb" >
    			<item text="All the Flowers Are Dying" id="lb_1" />
    			<item text="The Burglar on the Prowl" id="lb_2" />
    			<item text="The Plot Thickens" id="lb_3" />
    			<item text="Grifters Game" id="lb_4" />
    			<item text="The Burglar Who Thought He Was Bogart" id="lb_5" />
    		</item>
    		<item text="Robert Crais" id="rc" >
    			<item text="The Forgotten Man" id="rc_1" />
    			<item text="Stalking the Angel" id="rc_2" />
    			<item text="Free Fall" id="rc_3" />
    			<item text="Sunset Express" id="rc_4" />
    			<item text="Hostage" id="rc_5" />
    		</item>
    		<item text="Ian Rankin" id="ir" ></item>
    		<item text="James Patterson" id="jp" ></item>
    		<item text="Nancy Atherton" id="na" ></item>
    	</item>
    </cf_dhtmlXTree>

With Events Handlers,Checkboxes and Drag-n-drop:

    <cf_dhtmlXTree
    	dragndrop="true"
    	checkboxes="twoState"
    	onSelect="onClick"
    	onCheck="onCheck"
    	onDrop="onDrag">
    		<item text="Mystery " id="mystery"  open="yes" >
    			<item text="Lawrence Block" id="lb" >
    				<item text="All the Flowers Are Dying" id="lb_1" />
    				<item text="The Burglar on the Prowl" id="lb_2" />
    				<item text="The Plot Thickens" id="lb_3" />
    				<item text="Grifters Game" id="lb_4" />
    				<item text="The Burglar Who Thought He Was Bogart" id="lb_5" />
    			</item>
    			<item text="Robert Crais" id="rc" >
    				<item text="The Forgotten Man" id="rc_1" />
    				<item text="Stalking the Angel" id="rc_2" />
    				<item text="Free Fall" id="rc_3" />
    				<item text="Sunset Express" id="rc_4" />
    				<item text="Hostage" id="rc_5" />
    			</item>
    			<item text="Ian Rankin" id="ir" ></item>
    			<item text="James Patterson" id="jp" ></item>
    			<item text="Nancy Atherton" id="na" ></item>
    		</item>
    </cf_dhtmlXTree>

#### Editable Items

Since version 1.3 dhtmlxTree Professional got editable items. To make items text editable just add dhtmlXTree_ed.js to the page and enable this functionlity using one script line:

    <script  src="../js/dhtmlXTree_ed.js"></script>
    <script>
    	tree.enableItemEditor(mode);
    </script>

Parameters are:
- mode - mandatory - true/false - enable/disable Editable items
Event:
You can process various stages of editing item using the event handler, which can be set by setOnEditHandler method. Event occurs on 4 different stages of edit process: before editing started (cancelable), after editing started, before closing (cancelable), after closed. The function specified as input parameter for this method will get the following arguments:
- state - 0 before editing started , 1 after editing started, 2 before closing, 3 after closed
- id - id of edited items
- tree - tree object
- value - only for stage 2, value of editor

#### Simultanious Server Update

Common tree manipulations - like drag-n-drop (including d-n-d between trees), delete item, insert item, update item label - can be simultaniously reflected in server database now (since v.1.3) using dataProcessor module.
Main features of it are:
- Updated/Inserted item, marked with bold text, deleted - with line-through
- You can define the mode for data processing (automatic/manual).
Updated/deleted items' data sent to server to the URL you specified (we call it serverProcessor). serverProcessor should return simple xml of specified format (see below) to let tree know about successful or not successful processing. All necessary after-save procedures will be done automaticaly.
To enable this feature you need to do the following:
- include dhtmlXDataProcessor.js to the page
- create dataProcessor object for the tree:

    <script  src="../js/dhtmlXDataProcessor.js"></script>
    <script>
    	...
    	tree.init();
    	myDataProcessor = new dataProcessor(serverProcessorURL);
    	myDataProcessor.init(treeObj);
    </script>

Parameter for dataProcessor is:
- serverProcessorURL - mandatory - url of the file which will process incomming data. If you use our server-side routines, then it is "dhtmlxDataProcessor/server_code/PHP/update.php?ctrl=tree", where
Parameter for myDataProcessor.init is:
- treeObj - mandatory - tree object to assign dataProcessor to
If you do not use our built-in serverProcessor and use your own file for processing data sent by dataProcessor you need to know the following:
- All data comes in GET scope:
- tr_id - node ID
- tr_order - node sequense on the level
- tr_pid - parent ID
- tr_text - node text(label)
- userdata blocks passed with their names
- !nativeeditor_status - exists and value is "inserted" for insert operation, value is "deleted" for delete, doesn't exist or value is "updated" for update operation
- serverProcessor should return valid XML of the following format:

    	<data>
    		<action type='insert/delete/update' sid='incomming_node_ID' tid='outgoing_node_ID'/>
    	</data>

Where incomming_node_ID and outgoing_node_ID are different for insert action only. For other actions they are equel.
To use unified server-side routine (available for PHP5/mySQL) do the following:
- use "dhtmlxDataProcessor/server_code/PHP/get.php?ctrl=tree" for yourTree.loadXML(url)
- use "dhtmlxDataProcessor/server_code/PHP/update.php?ctrl=tree" for new dataProcessor(url)
- configure connection in dhtmlxDataProcessor/server_code/PHP/db.php
- specify table columns in dhtmlxDataProcessor/server_code/PHP/tree_data.xml for corresponding values

#### Initialize from HTML

You can create tree based on html LIST or inline XML. In both cases list or xml should be incapsulated into DIV element which will be tree container (xml should also be included into XMP tag - see code sample below).
Any of tree mathods which start with set or enable can be used as attributes of this DIV element to set\enable tree properties.
Convertion can be done automatically or calling script function.

##### Automatic convertion

- include dhtmlXTree_start.js into the page
- set class attribute of DIV element to dhtmlxTree

##### Convert with script function

- include dhtmlXTree_start.js into the page
- call dhtmlXTreeFromHTML function with id of DIV element to convert as first argument

    	var myTree = dhtmlXTreeFromHTML('listBox');

##### Init from html List

    	<div
    		class="dhtmlxTree"
    		id="treeboxbox_tree"
    		setImagePath="../imgs/"
    		style="width:250px; height:218px;overflow:auto;">

    		<ul>
    			<li>Root</li>
    			<ul>
    				<li>Child1
    				<ul>
    					<li>Child 1-1</li>
    				</ul>
    				</li>
    				<li>Child2</li>
    				<li><b>Bold</b> <i>Italic</i></li>
    			</ul>
    			</li>
    		</ul>
    	</div>

##### Init from inline XML

For more details about dhtmlxTree XML structure please see Loading data with XML

    	<div id="treeboxbox_tree2" setImagePath="../imgs/" class="dhtmlxTree" >
    	<xmp>
    		<item text="Root" open="1" id="11">
    			<item text="Child1" select="1" open="1" id="12">
    				<item text="Child1-1" id="13"/>
    			</item>
    			<item text="Child2" id="14"/>
    			<item id="15" text="Text"/>
    		</item>
    	< /xmp>
    	</div>

###### Version/Edition: v1.4/Professional/Standard

###### Required js file:dhtmlXTree_start.js

© DHTMLX LTD.