Location: PHPKode > projects > Neobill > NeoBill0.5.6/include/dhtmlxTree/doc/kb/faq.html
<div style="position:absolute;left:80%;background-color:white;right:20px;width:150px;">
<a onclick="expandAll(true)" href="javascript:void(0)">expand</a>|<a onclick="expandAll(false)" href="javascript:void(0)">collaps</a>
</div>
		<script type="text/javascript">
			
			function openFull(el){
				el.nextSibling.style.display=='none'?el.nextSibling.style.display='block':el.nextSibling.style.display='none'
			}
			function expandAll(fl){
				var elAr = document.getElementsByTagName("DIV");
				for(var i=1;i<elAr.length;i++){
					if(elAr[i].style.display=='none' || elAr[i].block_fl){
						elAr[i].block_fl = true;
						if(fl)
							elAr[i].style.display = "";
						else
							elAr[i].style.display = "none";
					}
				}
			}
			
		</script>
		<style type="text/css">
			body { font-family:arial;}
			h2 { cursor:pointer;font-size:16px;margin-left:10px;line-height:10px}
			h3 { cursor:pointer;font-weight:normal;color:gray;text-decoration:underline;line-height:10px}
			div.block { margin-left:30px;}
			xmp { color:green; background-color:silver; padding:3px;}
		</style>
<h2 onclick="openFull(this)">F.A.Q.</h2>
<div onclick="openFull(this)" style="display:block" class="block">
<a name="kb_faq_lic"></a><h3>Licensing</h3>
</div>
<div style="margin-left:5px;margin-top:2px;">
<div onclick="openFull(this)" style="margin-top:5px;color:blue;cursor:pointer;margin-top:10px;">
<li>May I use dhtmlxTree Standard Edition in my commercial projects for free?</li>
</div>
<div style="display:none;margin-left:20px;margin-top:2px;font-size:16px;">No. To use any edition in commercial project you need to purchase a Commercial or Enterprise License.</div>
<div onclick="openFull(this)" style="margin-top:5px;color:blue;cursor:pointer;margin-top:10px;">
<li>How much does the professional version cost? Is it included with the commercial license?</li>
</div>
<div style="display:none;margin-left:20px;margin-top:2px;font-size:16px;">You'll get Professional Edition when you purchase Commercial ($99) or Enterprise ($399) License.</div>
<div onclick="openFull(this)" style="margin-top:5px;color:blue;cursor:pointer;margin-top:10px;">
<li>What is the difference between Commercial and Enterprise Licenses?</li>
</div>
<div style="display:none;margin-left:20px;margin-top:2px;font-size:16px;">There are two main differences: 
<li>According to Enterprise license you may use dhtmlxTree in any number of your projects, whereas Commercial License allows using dhtmlxTree in one project per license</li>
<li>Supporting period (as well as period of free upgrade) is 1 month for Commercial and 1 year for Enterprise License.</li></div>
<div onclick="openFull(this)" style="margin-top:5px;color:blue;cursor:pointer;margin-top:10px;">
<li>How can I get Professional Edition of dhtmlxTree?</li>
</div>
<div style="display:none;margin-left:20px;margin-top:2px;font-size:16px;">To get Professional Edition of dhtmlxTree you need to purchase Commercial or Enterprise License. Right after that you'll get Professional Edition together with additional sample files by email.</div>
<div onclick="openFull(this)" style="margin-top:5px;color:blue;cursor:pointer;margin-top:10px;">
<li>Are the "pro" features available in the file downloaded from the site for evaluation, or do we have to buy a different file to try it out?</li>
</div>
<div style="display:none;margin-left:20px;margin-top:2px;font-size:16px;">You can download only Standard Edition from the site. If you want to evaluate Professional Edition please write us - hide@address.com</div>
<div onclick="openFull(this)" style="margin-top:5px;color:blue;cursor:pointer;margin-top:10px;">
<li>Will I get commented not obfuscated sources together with Professional Edition?</li>
</div>
<div style="display:none;margin-left:20px;margin-top:2px;font-size:16px;">Yes.</div>
<div onclick="openFull(this)" style="margin-top:5px;color:blue;cursor:pointer;margin-top:10px;">
<li>Is there some special documentation available with Professional Edition?</li>
</div>
<div style="display:none;margin-left:20px;margin-top:2px;font-size:16px;">No. There is only one variant of documentation. All methods specific for Professional Edition marked in documentation with red colored text "Professional" or "Commercial". </div>
<div onclick="openFull(this)" style="margin-top:5px;color:blue;cursor:pointer;margin-top:10px;">
<li>May I modify dhtmlxTree and use modified files in my project?</li>
</div>
<div style="display:none;margin-left:20px;margin-top:2px;font-size:16px;">Yes you may. At the same time according to the License Scand LLC remains the owner of all modifications in the code.</div>
<div onclick="openFull(this)" style="margin-top:5px;color:blue;cursor:pointer;margin-top:10px;">
<li>How to buy dhtmlxTree License?</li>
</div>
<div style="display:none;margin-left:20px;margin-top:2px;font-size:16px;">Please send email to hide@address.com and you'll get necessary instructions right away.</div>
<div onclick="openFull(this)" style="margin-top:5px;color:blue;cursor:pointer;margin-top:10px;">
<li>May I distribute dhtmlxTree as a part of my application? What License do I need for this? Should I buy additional License for each copy of my application?</li>
</div>
<div style="display:none;margin-left:20px;margin-top:2px;font-size:16px;">You may distribute dhtmlxTree as a part of you application if this application is not competitor to dhtmlxTree. You can use either Commercial or Enterprise License.  Only one license necessary for one application - irregardless to number of copies sold.</div>
<div onclick="openFull(this)" style="margin-top:5px;color:blue;cursor:pointer;margin-top:10px;">
<li>My licensing question regards including your dhtmlxtree code in a commercial product which will be redistributed and run on clients' machines.  I'm curious whether this would require a license on each client machine, or whether my company would simply need to license the code once for inclusion in the code base.</li>
</div>
<div style="display:none;margin-left:20px;margin-top:2px;font-size:16px;">Only once.</div>
<div onclick="openFull(this)" style="margin-top:5px;color:blue;cursor:pointer;margin-top:10px;">
<li>Can we modify dhtmlxTree code and/or change some functionalities in order to match our requirements.</li>
</div>
<div style="display:none;margin-left:20px;margin-top:2px;font-size:16px;">Modifications to the software are allowed, and you may distribute it as a part of your application, but distribution of the modified software as a standalone component or as a part of concurrent software is forbidden. </div>
</div>
<div onclick="openFull(this)" style="display:block" class="block">
<a name="kb_faq_perf" id="kb_faq_perf"><h3>Performance. Dynamical Loading</h3></a>
</div>
<div style="margin-left:5px;margin-top:2px;">
<div onclick="openFull(this)" style="margin-top:5px;color:blue;cursor:pointer;margin-top:10px;">
<li>How can I load xml dynamically, so that the loading gets done more quickly?</li>
</div>
<div style="display:none;margin-left:20px;margin-top:2px;font-size:16px;">
As you know dhtmlXTree supports dynamical loading for such purposes. Dynamical loading means loading data on request. To make tree do this use method <em>tree.setXMLAutoLoading(url)</em><br>
In this case your xml should contain only necessary nodes. For example initial xml should contain only nodes of top level. To let the tree know that some node has children, use child="1". Like this:
	<xmp>
	<tree id="0">
		<item  text="Surveillance" id="a1" im0="book.gif"  child="1"/>
		...
		<item text="Low income countries" id="a333" im0="book_titel.gif"  child="0"/>
	</tree>	
	</xmp>
When user trying to open node which has children, tree looks for data on client side first - if no data found, then it goes to server using URL specified in method mentioned above with ID of node added to it, like: http://127.0.0.1/myTree/tree.cfm?id=a1, where "a1" is ID of the node which should be opened. Using this ID you can create another xml, which contains only child nodes of opening node. Like this:
	<xmp>
	<tree id="a1">
		<item text="Bilateral surveillance" id="a2"  />
		...
	</tree>
	</xmp>
	
As dynamical loading needs to process incoming url parameters and generate xml file content based on it to work really useful, it would be good to use some server side programming language like ASP, ColdFusion, JSP, PHP or any other for this. 
</div>
<div onclick="openFull(this)" style="margin-top:5px;color:blue;cursor:pointer;margin-top:10px;">
<li>Is there any solution for increasing tree performance when it contains hundreds or thousands of nodes?</li>
</div>
<div style="display:none;margin-left:20px;margin-top:2px;font-size:16px;">There are two ways:<br>
<li>Dynamical loading. In this case tree contains only nodes which were already opened and it doesn't really matters how much nodes are in the datasource .</li>
<li>Advanced XML Processing (available in Professional edition). In this case the whole xml documents loaded on client side, but only nodes which are visible are created in tree. This increases performance and decreases loading time.</li></div>
<div onclick="openFull(this)" style="margin-top:5px;color:blue;cursor:pointer;margin-top:10px;">
<li>What happens is that the nodes get drawn as siblings of the root and not as children of the expanded node.</li>
</div>
<div style="display:none;margin-left:20px;margin-top:2px;font-size:16px;">The reason is in xml file. It always contains the same ID of parent element: <xmp><tree id="every-time-id-of-super-root-level"></xmp>, but it should be <xmp><tree id="id-of-node-that-was-expanded"></xmp></div>
<div onclick="openFull(this)" style="margin-top:5px;color:blue;cursor:pointer;margin-top:10px;">
<li>Dynamical Loading always loads the whole tree and adds it to existing one.</li>
</div>
<div style="display:none;margin-left:20px;margin-top:2px;font-size:16px;">XML file for initial loading should contain ONLY top level of the tree, xml that loads children should contain ONLY necessary nodes - so in most cases it generated with some server side routine using incoming "id" of parent node (node that was opened) which is passed to the file while calling it.</div>
<div onclick="openFull(this)" style="margin-top:5px;color:blue;cursor:pointer;margin-top:10px;">
<li>I've created simple xml containig 10 000 nodes and ... after 30second IE almost breaks down with a warning</li>
</div>
<div style="display:none;margin-left:20px;margin-top:2px;font-size:16px;">As performance is a weak place of DHTML, we implemented two ways of processing big trees. First is dynamical loading - xml loaded from server by parts (on request). This feature available in all editions. Second is "advanced xml processing" - xml loaded at once, but processed by parts on request. This feature available in pro edition only.</div>
</div>
<div onclick="openFull(this)" style="display:block" class="block">
<a name="kb_faq_dnd" id="kb_faq_dnd"><h3>Drag-n-drop, Nodes ordering</h3></a>
</div>
<div style="margin-left:5px;margin-top:2px;">
<div onclick="openFull(this)" style="margin-top:5px;color:blue;cursor:pointer;margin-top:10px;">
<li>Is there any way to rearrange the nodes without reloading the tree?</li>
</div>
<div style="display:none;margin-left:20px;margin-top:2px;font-size:16px;">You can rearrange nodes with script (moveItem method) or using drag-n-drop (drop-as-sibling type)</div>
<div onclick="openFull(this)" style="margin-top:5px;color:blue;cursor:pointer;margin-top:10px;">
<li>Can we use different drag-n-drop types for different nodes? For example we need drop-as-sibling for files and drop-as-child for folders.</li>
</div>
<div style="display:none;margin-left:20px;margin-top:2px;font-size:16px;">You can switch the drop mode on-the-fly. Using onDrag or onDrop event handlers you can manage the active mode based on some specificity of node which is dragged or dropped. To identify the type of the node you can use userData property of the node, which can be set with xml or with javascript: setUserData(itemId,name,value). Any time you can get the value of any block of user data of any node using getUserData(id,name)</div>
<div onclick="openFull(this)" style="margin-top:5px;color:blue;cursor:pointer;margin-top:10px;">
<li>Can I drag and drop either the node's id or value into the html text input field?</li>
</div>
<div style="display:none;margin-left:20px;margin-top:2px;font-size:16px;">Yes, this is possible. Any page control can be set as "landing zone". Here is an example:
<xmp>
	<div id="treeboxbox_tree" style="width:200px;height:200px"></div>
	<input type="text" width="120px" id="sInput">
	<script type="text/javascript">
		tree=new dhtmlXTreeObject("treeboxbox_tree","100%","100%",0);
		tree.setImagePath("../imgs/");
		//user defined drag and drop control with event handlers inside
		function s_control(){
			//action occures on drag
			this._drag = function(sourceHtmlObject, dhtmlObject, targetHtmlObject) {
				targetHtmlObject.style.backgroundColor="";
				targetHtmlObject.value=sourceHtmlObject.parentObject.label;
			}
	
			//action occures on drag moved in landing zone
			this._dragIn = function(htmlObject, shtmlObject){
				htmlObject.style.backgroundColor = "#fffacd";
				return htmlObject;
			}
	
			//action occures on drag moved out landing zone
			this._dragOut = function(htmlObject){
				htmlObject.style.backgroundColor = "";
				return this;
			}
		}
	//set input control as "landing zone"
	tree.dragger.addDragLanding(document.getElementById('sInput'), new s_control);	
	</script>
</xmp>
</div>
</div>
<div onclick="openFull(this)" style="display:block" class="block">
<a name="kb_faq_api" id="kb_faq_api"><h3>API, Initialization</h3></a>
</div>
<div style="margin-left:5px;margin-top:2px;">
<div onclick="openFull(this)" style="margin-top:5px;color:blue;cursor:pointer;margin-top:10px;">
<li>It seems that your tree does not make a distinction between "files" and "folders".  If I drag a "file" onto another "file", it becomes a "folder".</li>
</div>
<div style="display:none;margin-left:20px;margin-top:2px;font-size:16px;">Generally the tree can only output data, it knows nothing about files or folders - you need to supply it with additional data and manage its behavior with script to get functionality you need.<br>
First you need to specify what nodes are files and what are folders using UserData (invisible data blocks that you can assign to any node). In your xml file use syntax like this:
<xmp>
	<tree id="0">
		<item text="My Folder" id="my_folder" child="1" ...>
			<userdata name="folder">1</userdata>
			<item text="My File" id="my_file" child="0"  ...>
				<userdata name="folder">0</userdata>
			</item>
		</item>
	...
	</tree>
</xmp>
In script you can manipulate this data using script methods:

<em>tree.getUserData(nodeId,key)</em>, for example:
<xmp>
	function doOnSomeEvent(id){
	If(yourTree.getUserData(id,"folder")=='0')
				alert("This was file")
			else
				alert("This was folder")
	}
</xmp>
This way you can cancel drop event for files:
<xmp>
tree.setDragFunction(doOnDrop);
function doOnDrop(nodeId,parentId){
		if(tree.getUserData(parentId,"folder")=="0")
			return false;
}
</xmp>
For more details about eventHandlers see "Set Event Handlers" chapter of Tree documentation.
</div>
<div onclick="openFull(this)" style="margin-top:5px;color:blue;cursor:pointer;margin-top:10px;">
<li>How to collapse all nodes in the tree.</li>
</div>
<div style="display:none;margin-left:20px;margin-top:2px;font-size:16px;">To collapse all root nodes (nodes of first level) in the tree you need to close them all one by one:
<xmp>
	function closeAllRoots(){
		var rootsAr = tree.getSubItems(0).split(",")
		for(var i=0; i < rootsAr.length; i++){
			tree.closeAllItems(rootsAr[i])
		}
	}
</xmp>
where "0" is ID of Super Root level.</div>
<div onclick="openFull(this)" style="margin-top:5px;color:blue;cursor:pointer;margin-top:10px;">
<li>Is there a way to get a modified tree back to xml?</li>
</div>
<div style="display:none;margin-left:20px;margin-top:2px;font-size:16px;">Yes, you can use serializeTree() method for this. It returns xml string. </div>
<div onclick="openFull(this)" style="margin-top:5px;color:blue;cursor:pointer;margin-top:10px;">
<li>How can I have different nodes call different functions when clicked?</li>
</div>
<div style="display:none;margin-left:20px;margin-top:2px;font-size:16px;">You can use userData to keep function name for each node. In onclick event handler get this name and evaluate it.</div>
<div onclick="openFull(this)" style="margin-top:5px;color:blue;cursor:pointer;margin-top:10px;">
<li>How to create nodes in tree and save them to db at the same time?</li>
</div>
<div style="display:none;margin-left:20px;margin-top:2px;font-size:16px;">1.	user clicks button "add new item" (or whatever you have for this) <br>
2.	create node in the tree with some unique identifier, like "newnodeid" and label like "New" or something. (Do not forget to call open node method before this if you use dynamical loading, inserting node as child and parent node was never opened before) <br>
3.	move selection to the node with calling onclick function  (last parameter should be true)<br>
4.	determine that node id is "newnodeid" and load the form for creating new item. <br>
5.	when form was submitted and data was saved on server return the page with added javascript block which should rename selected node according to entered name or whatever you need as a  node label, set new node id - according to created record id (or whatever you have as node ids). <br>
6.	Delete and update should be done very likely. <br>
7.	Do not forget the main principle - update the tree after database was updated. </div>
<div onclick="openFull(this)" style="margin-top:5px;color:blue;cursor:pointer;margin-top:10px;">
<li>Can we limit the "maximum depth" of the tree to disallow child-dropping beyond a certain number of sub-nodes?</li>
</div>
<div style="display:none;margin-left:20px;margin-top:2px;font-size:16px;">You can get the level of the node in onDrop event handler and cancel drop if it exceeds maximum allowed.</div>
<div onclick="openFull(this)" style="margin-top:5px;color:blue;cursor:pointer;margin-top:10px;">
<li>Can we use HTML as a node label?</li>
</div>
<div style="display:none;margin-left:20px;margin-top:2px;font-size:16px;">Yes.</div>
<div onclick="openFull(this)" style="margin-top:5px;color:blue;cursor:pointer;margin-top:10px;">
<li>Serialization of the modified trees - how does that work?</li>
</div>
<div style="display:none;margin-left:20px;margin-top:2px;font-size:16px;">Using <em>serializeTree()</em> method you can get back tree structure as xml string. In version 1.1 it serializes node text, icons, state, order, selection. Version 1.2 will support serialization of userData, checkboxes.</div>
</div>
<div onclick="openFull(this)" style="display:block" class="block">
<a name="kb_faq_else" id="kb_faq_else"><h3>Other Questions</h3></a>
</div>
<div style="margin-left:5px;margin-top:2px;">
<div onclick="openFull(this)" style="margin-top:5px;color:blue;cursor:pointer;margin-top:10px;">
<li>Is there any support for cookies?</li>
</div>
<div style="display:none;margin-left:20px;margin-top:2px;font-size:16px;">Yes, Professional Edition has the ability to save tree state into cookies and restore it. There are two types of this functionality:
	<li>save the whole tree (not good for large trees as cookies has size limit)</li>
	<li>save only opened/closed/selected state.</li></div>
<div onclick="openFull(this)" style="margin-top:5px;color:blue;cursor:pointer;margin-top:10px;">
<li>Is there any ability to use context menu (right-click menu) with dhtmlxTree </li>
</div>
<div style="display:none;margin-left:20px;margin-top:2px;font-size:16px;">Context menu implemented into dhtmlxTree v.1.1 Professional Edition - the content of the menu can be defined with xml or javascript and can be managed with javascript.</div>
<div onclick="openFull(this)" style="margin-top:5px;color:blue;cursor:pointer;margin-top:10px;">
<li>What is Super Root in the dhtmlxTree?</li>
</div>
<div style="display:none;margin-left:20px;margin-top:2px;font-size:16px;">When you create tree from constructor function, there is 4th parameter which represents the ID of Super Root element. Usually it is "0". Super Root is invisible level of the tree - the parent element for elements of  first visible level ("root level").</div>
<div onclick="openFull(this)" style="margin-top:5px;color:blue;cursor:pointer;margin-top:10px;">
<li>Is it possible to use multiple-lines for a dhtmlxTree node?</li>
</div>
<div style="display:none;margin-left:20px;margin-top:2px;font-size:16px;">Yes, there is such possibility in Professional Edition. The only limitation for current version - tree should not have dotted lines which visually link nodes (they should be turned off using enableTreeLines(false)) - otherwise appearance will be damaged.</div>
<div onclick="openFull(this)" style="margin-top:5px;color:blue;cursor:pointer;margin-top:10px;">
<li>I use various dhtmlX components on one page - tree, toolbar, menu. All of them have dhtmlxCommon.js file. Is it the same for all of them?</li>
</div>
<div style="display:none;margin-left:20px;margin-top:2px;font-size:16px;">Yes, it is the same and you can get it either from tree package or from menu, toolbar - any dhtmlX component. If you have different versions of this file - would be better to use most recent.</div>
</div>
Return current item: Neobill