Start Building Professional
Web Apps Today


 
Categories Question details Back To List
Question  posted by Amal on Dec 08, 2009 03:17
open dhtmlx forum
DhtmlxTree On Demand loading

Now we require to implement the Dhtmlx Tree which is taking more time to display data. we are fetching 400 hundred rows from database through stored procedure. The below sample data converted into tree structure by calling the below recursive function from page load.Where we have to make change in order to implement the on demand.Please help us to resolve this constraint ASAP.


function recTreeView(intPID,strTagName,bindContent)
{

var strVal='';
var t = XmlReq.responseXML.documentElement.getElementsByTagName(strTagName);
for(var intCnt=0;intCnt<t.length;intCnt++)
{
if(fnGetNodeText(t[intCnt].getElementsByTagName("PARENTID")[0])==intPID)
{
strVal +='<item id=\"'+fnGetNodeText(t[intCnt].getElementsByTagName("ID")[0])+'\"';
strVal +=' text=\"'+fnGetNodeText(t[intCnt].getElementsByTagName("NAME")[0])+'\">';
strVal +=recTreeView(fnGetNodeText(t[intCnt].getElementsByTagName("ID")[0]),strTagName,bindContent);
strVal +='</item>';
}
}
return strVal;
}

var tree;
function PageOnLoad()
{


tree = new dhtmlXTreeObject("treeboxbox_tree", "100%", "100%", 0);
tree.setImagePath("../dhtmlxTree/codebase/imgs/csh_bluebooks/");
tree.setOnClickHandler(tonclick);
tree.enableDragAndDrop(true);
tree.loadXMLString("<tree id=\"0\">"+fetchTreeView("Table")+"</tree>");
}

function fetchTreeView(nodeName,bindContent)
{
return recTreeView("0",nodeName,document.getElementById("hidTreeValue").value);
}

function fnGetNodeText(xmlObjNode)
{
//if(window.ActiveXObject)
if(_isIE)
{
//alert(xmlObjNode.text);
return xmlObjNode.text;
}
else
{
//alert("fnGetNodeText Value:" +xmlObjNode.childNodes[0].nodeValue);
if(xmlObjNode&&xmlObjNode.childNodes.length>0)
return xmlObjNode.childNodes[0].nodeValue;
else
return "";
}
}



ID    NAME     PARENTID

16    Application     0
17    3rd Party Applications    16
18    Compatibility issues    17
19    Unable to install    17
20    Unable to launch    17
21    Unable to uninstall     17
22    Unexpected behavior (crash)    17
23    Inbox MS Vista Applications    16
24    Accessories (Calculator, Paint...)    23
25    Action Center (Win 7)    23
26    Bluetooth file transfer wizard    23
27    Calendar    23
28    Contacts    23
29    DVD Maker    23
30    Fax and Scan    23
31    Games    23
32    Magnifier    23
Answer posted by Alex (support) on Dec 08, 2009 03:31

There are different ways to improve performance. For example dynamic loading or Smart XML Parsing (the last one is available only in PRO edition).

Please, see details in the article:

http://dhtmlx.com/dhxdocs/doku.php?id=dhtmlxtree:increasing_tree_s_performance

Answer posted by Amal on Dec 08, 2009 05:35

Thanks alex.  Could you give some example for this tree structure.

Regards,

amal.

Answer posted by Alex (support) on Dec 08, 2009 06:26

The examples of xml structures for all components can be found here http://www.dhtmlx.com/docs/products/docsExplorer/doc/dhtmlxxml/index.html