dtree ajax

<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Insert title here</title>
 <script src="jquery-1.4.2.min.js"></script>
  <link rel="StyleSheet" href="dtree.css" type="text/css" />
<script type="text/javascript" src="dtree.js"></script>
 <script type="text/javascript">
$(document).ready(function(){
//获取顶级部门
d = new dTree('d');
d.add(0,-1,'系统');
$.ajaxSetup({cache:false});
   $.getJSON("getTreeNode.action",function call(data){
    var org=eval("("+data+")"); 
   // alert(org.length);
      
        for(var i=0;i<org.length;i++){ 
       // alert(org[0].id);
         //id, pid, name, url, title, target, icon, iconOpen, open
         d.add(org[i].id,0,org[i].desc,"javascript:addNextOrg('"+org[i].id+"');",'测试节点');

         }
        $("#showDtree").html(d.toString());
     });
});
//获取下级部门
function addNextOrg(ID){
  $.getJSON("getTreeNode.action?id="+ID,function call(data){
  //	alert(data);
    var org1=eval("("+data+")");   
    alert(org1.length);
    if(org1.length!=0){ 
        for(var i=0;i<org1.length;i++){ 
        alert(org1[i].id);
         d.add(org1[i].id,ID,org1[i].desc,"javascript:addNextOrg('"+org1[i].id+"');",'测试节点');
       }
        $("#showDtree").html(d.toString());
    
    }
   });
}

/*
function showformDiv(id){
 $('.formDiv').hide();
 $(id).show();
 
}

function buildOrg(){
 var str=$("#buildOrg").serialize();
 
alert(str);
   $.getJSON("/simple/DynajetServlet?Method=buildOrg&"+str,function call(data){  
    var result=data.result;    
  //  alert("hello");
         $("#result").text(result);
     });
 
}*/
 
 
 /*
function orgChange(){
 $.ajaxSetup({cache:false});
 var orgId=$("#orgList").val();
 alert(orgId);
   $.getJSON("/simple/SalesServlet?Method=getRoleJson&orgId="+orgId,function call(data){  
    var continents =data.roleList;    
        for(var i=0;i<continents.length;i++){ 
        $("#roleList").append('<option value='+continents[i].roleId+'>'+continents[i].description+'</option>'); 
        }
     });
}
*/
</script>
</head>
<body>
<div id="showDtree">
</div>
</body>
</html>

相关推荐