Start Building Professional
Web Apps Today


 
Categories Question details Back To List
Question  posted by ankit on Jun 11, 2009 22:24
open dhtmlx forum
unable to show (+/-)

hi,
I am using a dhtmlxtree. wch works fine,bt a small prob. is tht ,at the very first time it doesn't show me plus minus(+/-) sign.
In place of (+/-) it is showing a image "blank.gif". wen i click on tht area den it shows me (+/-)sign as usual.But dis prob. continue wid it's child node ,means if a child node also have  its child den at d first time it is indicating by blank image again & same like above on d click of tht blank image i  am able to show (+/-) sign respectively.I want 2 show plus minus sign in the starting as d tree loaded.Can u help me.
plz also send a sample code.
thnkx

<script language='javascript'>

mytree = new dhtmlXTreeObject("treebox","100%","95%",'0');

mytree.setImagePath("<%=appName%>/tpc/dhtmlx/dhtmlxTree/codebase/imgs/");

mytree.enableTreeLines(false);

//mytree.enableTreeImages(true);

//mytree.enableTextSigns("true");

mytree.enableHighlighting(true);

mytree.showItemSign("treebox",true);

mytree.setIconSize(12,12);

mytree.setOnClickHandler(openUnits);

mytree.setOnOpenHandler(edit4TreeGrid);

mytree.insertNewChild('0','1^<%=TGlobalServlet.topUnitId%>','<%=TGlobalServlet.topUnitId%>', 0,0,0,0,"TOP,CHILD");

mytree.setUserData('1^<%=TGlobalServlet.topUnitId%>',"ORG_LEVEL",1);

mytree.openAllItems();

hideLoadingMsg();

</script>

======================================

 

function edit4TreeGrid(unitId,open)

{

      if(open==0){

      parForTree= unitId;

      var parUnit = unitId.split('^');

       var orgLevel = mytree.getUserData(unitId,"ORG_LEVEL")

      HRService.getUnitsDetails(<%=ownerId%>,'<%=clientId%>',parUnit[1],orgLevel,callBackTree);

     }

    else

   {

     return true;

    }

}

 

=============================================

function callBackTree(data)

{

for(var i=0; i<data.length;i++)

{

var dataArr = data[i];

mytree.insertNewChild(parForTree,dataArr[4]+"^"+dataArr[0],dataArr[1],0,0,0,0,"TOP,CHILD");

mytree.setUserData(dataArr[4]+"^"+dataArr[0],"ORG_LEVEL",dataArr[4]);

}

}

Answer posted by Alex (support) on Jun 12, 2009 02:26

Hello,

the provided code demonstrates the following behavior: there is one node initially. But when you click on it - child nodes must be loaded.

There is a special functionality in tree - dynamic loading. So, you don't need to set own event handlers in this case. Moreover "child" attribute, that shows + sign for items without child nodes, works only with dynamic loading. So, you should use dynamic loading in any case.

Just include the following code instead of mytree.setOnOpenHandler(edit4TreeGrid);

mytree.setXMLAutoLoading(edit4TreeGrid);

mytree.setXMLAutoLoadingBehaviour("function");

function edit4TreeGrid(unitId){

/*your code here*/

}