Start Building Professional
Web Apps Today


 
Categories Question details Back To List
Question  posted by Steve Boulay on Jun 05, 2009 08:12
open dhtmlx forum
dhtmlTree Stack Overflow with loadCSVString

when i initialise my tree with a csvstring, i have a stack overflow error.
Is just a test to verify performance of DHMTLXTree.
Thanks

My code is :

var treeCSV="";
for( wi = 1 ; wi < 10 ; wi++ )
{
    treeCSV+=wi.toString()+",0,New Node "+wi+"\n";
    for( wj=0;wj<10;wj++)
    {
     treeCSV+=((wi*1000)+(wj*100)).toString()+","+wi+",New Node "+wi+"."+wj+"\n";
     for(wk=0;wk<15;wk++)
     {
            treeCSV+=((wi*1000)+(wj*100)+wk).toString()+","+((wi*1000)+(wj*100))+",New Node "+wi+"."+wj+"."+wk+"\n";
        }
        
    }
}
tree.loadCSVString(treeCSV);
Answer posted by Support on Jun 05, 2009 08:22
With such CSV generation logic, the top item will have

1000,1000,some text

so its ID will be equal to its parent ID - which is definitely incorrect - it cause infinity loop and stack overflow in result. 
You can change your code as 
    for(wk=1;wk<15;wk++)  
to make it workable

By the way CSV is the slowest format for data loading ( it need to be reconstructed to hierarchy, which takes additional time ) 
Also, if you are using pro version, be sure to add

tree.enableSmartXMLParsing(true)

before loadCSVString command - it will greatly increase rendering performance.