<script type="text/javascript" src="../include/js/Bzlxdtree.js"></script>
<table class="bigtable" cellpadding="2" cellspacing="0">
<TR class="biaoti">
<TD width="35%"><a href="javascript:get_org_tree(1141);" >shu</a></TD>
</TR>
</table><table > <tr>
<td><script type='text/javascript'>
function get_org_tree(user_id)
{
    resourceTree.get_org_tree(user_id,show_tree);
}
function show_tree(list)
{
   for(var i=0;i<list.length;i++)
   {
  if(list[i].parent_id == 99999)
  {
          list[i].parent_id = -1;
          }
          tree.add( list[i].resource_id,list[i].parent_id,"'"+list[i].resource_name+"'");
 
}  
   document.write(tree);
   
   
}
</script> 
运用DWR获得一个存放内容的list,用树将内容显示出来
运行后能显示树(但只能显示一级目录)但是点上去的时候  不能显示子节点....
查看 错误显示是:tree未定  急求高手帮忙解决

解决方案 »

  1.   

    <script type='text/javascript'> 
    var tree = new dTree('d');这个tree你得声明一下
      

  2.   

    <%@ page contentType="text/html;charset=utf-8" language="java"%>
    <%@ taglib uri="http://struts.apache.org/tags-html" prefix="html"%><script type="text/javascript" src="../include/js/Bzlxdtree.js"></script>
    <script src='http://<%=request.getLocalAddr()%>:<%=request.getLocalPort()%>/e-touch/dwr/engine.js'></script>
    <script src='http://<%=request.getLocalAddr()%>:<%=request.getLocalPort()%>/e-touch/dwr/util.js'></script>
    <script src='http://<%=request.getLocalAddr()%>:<%=request.getLocalPort()%>/e-touch/dwr/interface/resourceTree.js'></script><script type="text/javascript">
        tree = new dTree("tree");
    tree.config.folderLinks=true;
    tree.config.useCookies=false;
    <!--
    function select_bm(ob)
    {       if (ob.checked == true){
          // alert(ob.name+";"+document.getElementById(ob.name).checked);
           if(ob.name!=1&&document.getElementById(ob.name).checked==false){
             
              
           }else{
           ob.disabled='';
           document.all.submit_node.value=document.all.submit_node.value+ob.value+",";
           var a_node_ob= document.getElementsByName(ob.value);
           for(var i=0;i<a_node_ob.length;i++){
           var node_ob=a_node_ob[i];
           if(node_ob!=null){
           if(node_ob.checked==false)
           node_ob.click();
           
           }
           }
           }
           
       }else{
           
           document.all.submit_node.value=document.all.submit_node.value.replace(ob.value+',','');
           var a_node_ob= document.getElementsByName(ob.value);
        
           for(var i=0;i<a_node_ob.length;i++){
           var node_ob=a_node_ob[i];
           if(node_ob!=null){
           if(node_ob.checked==true)
        
           node_ob.click();
           }
           }
       }
      


    }function chk1(input1,input2,id)
    {
        var id_a=id;
        var objForm = document.forms[input1];
        var objLen = objForm.length;
        for (var iCount = 0; iCount < objLen; iCount++)
        {
            if (input2.checked == true)
            {
                if (objForm.elements[iCount].type == "checkbox"&&objForm.elements[iCount].id== id)
                {
                    objForm.elements[iCount].checked = true;
                }
            }
            else
            {
                if (objForm.elements[iCount].type == "checkbox"&&objForm.elements[iCount].id== id)
                {
                    objForm.elements[iCount].checked = false;
                }
            }
        }
    }
    //-->
    </script><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
    <html>
    <head>
    <title></title>
    <meta http-equiv="expires" content="0">
    <meta http-equiv="pragma" content="no-cache">
    <meta http-equiv="cache-control" content="no-cache">
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
    <meta http-equiv="Content-Language" content="zh-cn">
    <link href="/e-touch/pages/include/css/main.css" rel="stylesheet" type="text/css"></head><script language="javascript">
     
    </script><body leftmargin="0" topmargin="0"><table class="bigtable" cellpadding="2" cellspacing="0">
    <TR class="biaoti">
    <TD width="33%"><a href="javascript:tree.closeAll();" > 全部收集</a></TD>
    <TD width="33%"><a href="javascript:tree.openAll();" >全部展开</a></TD>
    <TD width="34%"><a href="javascript:window.location.reload();" >刷新</a></TD>
    <TD width="35%"><a href="javascript:get_org_tree(1141);" >shu</a></TD>
    </TR>
    </table><table > <tr>
    <td><script type='text/javascript'>
    function get_org_tree(user_id)
    {
        resourceTree.get_org_tree(user_id,show_tree);
    }
      //resource_id;
        //resource_name;
        //parent_id;//所属的父节点,如果是node_type是channel,那么这里就是device_id ....
        //channel_no;//cno
        //node_type;
    function show_tree(list)
    {
       for(var i=0;i<list.length;i++)
       {
      if(list[i].parent_id == 99999)
      {
              list[i].parent_id = -1;
              }
      //alert(list[i].resource_id+" "+list[i].parent_id+" "+list[i].resource_name);
              tree.add( list[i].resource_id,list[i].parent_id,list[i].resource_name);
       }  
       document.write(tree);
    }
    </script> 
    </td>
    </tr>
    </table></body>
    </html>
      

  3.   

    你发了两个html,请问你第二个html中的tree对象在哪里定义了,难道我和老紫竹说的不对吗?