Start Building Professional
Web Apps Today


 
Categories Question details Back To List
Question  posted by daniel on Oct 16, 2009 07:24
open dhtmlx forum
tree initialization from xml

Hi, I have this question

I am creating a tree from htm (<li><ul> tags) and I want to know if is posible set a branch as "open"

What attribute must I write ? It could be something like this?

<div id="treeboxbox_tree" setimagepath="../../includes/components/codebase/imgs/csh_vista/" class="dhtmlxTree">

<ul>
<li open="1">TITLE 1

<ul>
<li>OPTION 1</li>
</ul>

</ul>

</div>

Another isssue:
If I choose initialization from xml, how I can set an option as link?

Is this code wright?
<xmp>
<item text="Root" open="1" id="11">
<item text="Child1" select="1" open="1" id="12">
<a href=mipage.asp>Go to page</a>
</item>
<item text="Child2" id="14"/>
</item>
</xmp>




Thanks in advance

Answer posted by Alex (support) on Oct 19, 2009 02:32

Hello, 

in order to open item in case of html initialization you can use openItem method. But in this case instead of dhtmlxTree class you should use dhtmlXTreeFromHTML to get tree object (http://dhtmlx.com/docs/products/dhtmlxTree/samples/09_initialization_general_settings/02_tree_init_from_html.html):

<body onload="initTree()">

<div id="treeboxbox_tree" setimagepath="../../includes/components/codebase/imgs/csh_vista/"> 
<ul> 
<li open="1" id="id1">TITLE 1 
<ul> 
<li>OPTION 1</li> 
</ul> 

</ul> 
</div>

function initTree(){

var myTree = dhtmlXTreeFromHTML('listBox');

myTree.openItem('id1');

}

In case of xml structure you can use place html into text attribute:

<item text="&lt;a href='some.html'&gt;link&lt;/a&gt;" open="1" id="11">