I have scoured the internet and this website for an answer to this question and I have yet to see it. My apologies if I missed a post.
What I am trying to do is populate a tree in Javascript using data that is returned from an SQL query.
The SQL query will return the following data...
ROOT_NODE_ID LEVEL1_ID LEVEL1_NAME LEVEL2_ID LEVEL2_NAME LEVEL3_ID LEVEL3_NAME LEVEL4_ID LEVEL4_NAME LEVEL5_ID LEVEL5_NAME LEVEL6_ID LEVEL6_NAME LEVEL7_ID LEVEL7_NAME LEVEL8_ID LEVEL8_NAME LEVEL9_ID LEVEL9_NAME LEVEL10_ID LEVEL10_NAME
Example...
Root (ROOT_NODE_ID)
Company 1 (LEVEL1_ID)
Location 1 (LEVEL2_ID)
Information1 (LEVEL3_ID)
Location 2 (LEVEL2_ID)
Company 2 (LEVEL1_ID)
-ROOT_NODE_ID (ROOT) points to the parent of the current node.
-LEVEL1_ID (Company 1) points to the Child of the root
-LEVEL2_ID (Location 1) points to the Child of LEVEL1_ID
-LEVEL3_ID (Information 1) points to the Child of LEVEL2_ID
-Company 2 would be created the same way with another row of data from the SQL query
-Location 2's ROOT_NODE_ID would equal Company 1, because Company 1 is the parent of Location 2
I hope this makes sense. I am currently using jquery and this is how I'm building my tree...
$(function(){
$("#tree2").dynatree({
checkbox: true,
}
});
var rootNode = $("#tree2").dynatree("getRoot");
// Call the DynaTreeNode.addChild() member function and pass options for the new node
//Adding Root
var Root = rootNode.addChild({
title: "Root",
});
//Adding Level 1
var Company1 = Root.addChild({
title: "Company 1",
});
//Adding Level 1
var Company2 = Root.addChild({
title: "Company 2",
});
//Adding level 2
var Location1 = Company1.addChild({
title: "Location 1",
});
//Adding level 2
var Location2 = Company1.addChild({
title: "Location 2",
});
//Adding level 3
var Information1 = Location1.addChild({
title: "Information 1",
});
});
mh
<metadata>
<item name="ROOT_NODE_ID" type="xs:decimal" precision="38" />
<item name="LEVEL1_ID" type="xs:string" length="2002" />
<item name="LEVEL1_NAME" type="xs:string" length="512" />
<item name="LEVEL2_ID" type="xs:string" length="2002" />
<item name="LEVEL2_NAME" type="xs:string" length="512" />
<item name="LEVEL3_ID" type="xs:string" length="2002" />
<item name="LEVEL3_NAME" type="xs:string" length="512" />
<item name="LEVEL4_ID" type="xs:string" length="2002" />
<item name="LEVEL4_NAME" type="xs:string" length="512" />
<item name="LEVEL5_ID" type="xs:string" length="2002" />
<item name="LEVEL5_NAME" type="xs:string" length="512" />
<item name="LEVEL6_ID" type="xs:string" length="2002" />
<item name="LEVEL6_NAME" type="xs:string" length="512" />
<item name="LEVEL7_ID" type="xs:string" length="2002" />
<item name="LEVEL7_NAME" type="xs:string" length="512" />
<item name="LEVEL8_ID" type="xs:string" length="2002" />
<item name="LEVEL8_NAME" type="xs:string" length="512" />
<item name="LEVEL9_ID" type="xs:string" length="2002" />
<item name="LEVEL9_NAME" type="xs:string" length="512" />
<item name="LEVEL10_ID" type="xs:string" length="2002" />
<item name="LEVEL10_NAME" type="xs:string" length="512" />
</metadata>
<data>
<row>
<value>5</value>
<value>5</value>
<value>Global Root</value>
<value>10</value>
<value>Company</value>
<value>100001</value>
<value>Customer</value>
<value>100002</value>
<value>Customer Site</value>
<value>120000</value>
<value>Location</value>
<value xs:nil="true" />
<value xs:nil="true" />
<value xs:nil="true" />
<value xs:nil="true" />
<value xs:nil="true" />
<value xs:nil="true" />
<value xs:nil="true" />
<value xs:nil="true" />
<value xs:nil="true" />
<value xs:nil="true" />
</row>
</data>