论坛首页 Web前端技术论坛

Ajax获取数据动态树形节点实现

浏览 3484 次
精华帖 (0) :: 良好帖 (0) :: 新手帖 (0) :: 隐藏帖 (0)
作者 正文
   发表时间:2010-04-18  

  下面是实现:

<%@ 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="../js/jquery-latest.js"></script>
  <script src="../js/select.js"></script>
  <link rel="StyleSheet" href="/sch/js/dtree.css" type="text/css" />
<script type="text/javascript" src="/sch/js/dtree.js"></script>
 <script type="text/javascript">
$(document).ready(function(){
//获取顶级部门

d = new dTree('d');
d.add(0,-1,'系统');
$.ajaxSetup({cache:false});
   $.getJSON("/sch/GetJsonServlet?Method=getTopOrgJson",function call(data){
    var org=data.orgList;
    alert(org.length);
     
        for(var i=0;i<org.length;i++){
         //id, pid, name, url, title, target, icon, iconOpen, open
         d.add(org[i].ID,0,org[i].description,"javascript:addNextOrg('"+org[i].ID+"');",'测试节点');


         }
        $("#showDtree").html(d.toString());
     });

});
//获取下级部门
function addNextOrg(ID){
 alert("hello");
  $.getJSON("/sch/GetJsonServlet?Method=getNextOrgJson&ID="+ID,function call(data){
    var org=data.orgList;  
    if(org.length!=0){
        for(var i=0;i<org.length;i++){
         d.add(org[i].ID,ID,org[i].description,"javascript:addNextOrg('"+org[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>
<body>
<div id="showDtree">

</div>

</body>
</html>

   发表时间:2010-04-19  
您好,这两个js一定需要?
   <script src="../js/jquery-latest.js"></script>
  <script src="../js/select.js"></script>
0 请登录后投票
   发表时间:2010-04-20  
第二个不需要
0 请登录后投票
论坛首页 Web前端技术版

跳转论坛:
Global site tag (gtag.js) - Google Analytics