前台js脚本为:
function pageInit(){
var customerId = <%=request.getParameter("customer") %>;
CustomerAction.CustomerAgencyList(customerId,function(lCustomerDept){
var x=0;
var y=-1;
var comp;
var customer;
var customername;
d = new dTree('d');
for(var i=0; i<lCustomerDept.length; i++){
customer = lCustomerDept[i];
if(customer.isTop==true){
d.add(x,y,customer.deptName);
comp=customer.deptCode;
}
}
getTree(lCustomerDept,comp,x,d);
document.write(d);
d.openAll();
}
);
}
function getTree(lCustomerDept,parentCode,x,d){
for(var i=0;i<lCustomerDept.length;i++){
if(lCustomerDept[i].isTop!=true&&lCustomerDept[i].parentCode==parentCode){
d.add(i,x,lCustomerDept[i].deptName,'','','','');
getTree(lCustomerDept,lCustomerDept[i].deptCode,i,d);
}
}
}
其中从后台获取数据没问题,已经取得,且树也能显示出来,默认为全部展开,但是点击相应节点却不能收缩,跟踪js后发现是点击时要触发一个d.o()的一个事件,提示d未定义。郁闷额,帮帮忙,拜托啦!
------解决方案--------------------