Categories | Question details Back To List | ||
unable to show (+/-) hi, < 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*/ } |