欧美大屁股bbbbxxxx,狼人大香伊蕉国产www亚洲,男ji大巴进入女人的视频小说,男人把ji大巴放进女人免费视频,免费情侣作爱视频

歡迎來(lái)到入門教程網(wǎng)!

AJAX相關(guān)

當(dāng)前位置:主頁(yè) > 網(wǎng)絡(luò)編程 > AJAX相關(guān) >

ajax請(qǐng)求后臺(tái)得到j(luò)son數(shù)據(jù)后動(dòng)態(tài)生成樹形下拉框的方法

來(lái)源:本站原創(chuàng)|時(shí)間:2020-01-11|欄目:AJAX相關(guān)|點(diǎn)擊: 次

如下所示:

<select id="cc" class="easyui-combotree" style="width:580px;" name="rempId" data-options="required:true"></select>

<script>

$(function(){
$.ajax({
url:"departmentAction_getAllDep.action",
type:"post",
success:function(result){
//console.log(result);
$("#cc").combotree('loadData',b1(result));
}
});
$("#cc").combotree({
animate:true,
//選擇樹節(jié)點(diǎn)觸發(fā)事件 
 onSelect : function(node) { 
 n = node;
  //返回樹對(duì)象 
  var tree = $(this).tree; 
  //選中的節(jié)點(diǎn)是否為葉子節(jié)點(diǎn),如果不是葉子節(jié)點(diǎn),清除選中 
  var isLeaf = tree('isLeaf', node.target); 
  if (!isLeaf) { 
   //清除選中 
   $("#cc").combotree('clear'); 
  } 
 } 
});
});

var tree = {
id:'', 
 text:'', 
 state:'', 
 checked:'', 
 iconCls:'',
 attributes:'', 
 children:''
}

function b1(result){
var t = [];
$.each(result,function(index,dept){
t[index] = b2(dept);
});
return t;
}

function b2(dept){
  var tree = new Object();
tree.id = dept.depId; 
 tree.text = dept.depName; 
 tree.state = 'closed'; 
 tree.checked = 'false';
 if(dept.employees.length != 0){
 tree.children = b3(dept.employees);
 }else{
 tree.children = [];
 }
 return tree;
}

function b3(employees){ 
 var easyTree = []; 
 $.each(employees,function(index,item){ 
 easyTree[index] = b4(item); 
 }); 
 return easyTree; 
} 
 
function b4(item){
var tree = new Object();
tree.id = item.empId;
tree.text = item.empName;
if(item.empSex == "男"){
tree.iconCls = 'icon-nan';
}else{
tree.iconCls = 'icon-female';
}
return tree;
} 

</script>

department表中的dept_id作為employee表中有的外鍵,生成的Department.java類中有Set<employee>對(duì)象。從后臺(tái)查詢部門表,得到List<Department>集合,通過(guò)struts2配置:

<action name="departmentAction_*" class="com.chinasoft.action.DepartmentAction" method="{1}">
<result name="getAllDep" type="json">
<param name="root">list</param>
</result>
</action>

轉(zhuǎn)成json格式后,傳到j(luò)sp頁(yè)面,在前臺(tái)頁(yè)面中處理json數(shù)據(jù),動(dòng)態(tài)生成下拉樹。

以上這篇ajax請(qǐng)求后臺(tái)得到j(luò)son數(shù)據(jù)后動(dòng)態(tài)生成樹形下拉框的方法就是小編分享給大家的全部?jī)?nèi)容了,希望能給大家一個(gè)參考,也希望大家多多支持我們。

上一篇:layui的checbox在Ajax局部刷新下的設(shè)置方法

欄    目:AJAX相關(guān)

下一篇:沒(méi)有了

本文標(biāo)題:ajax請(qǐng)求后臺(tái)得到j(luò)son數(shù)據(jù)后動(dòng)態(tài)生成樹形下拉框的方法

本文地址:http://mengdiqiu.com.cn/a1/AJAXxiangguan/11308.html

網(wǎng)頁(yè)制作CMS教程網(wǎng)絡(luò)編程軟件編程腳本語(yǔ)言數(shù)據(jù)庫(kù)服務(wù)器

如果侵犯了您的權(quán)利,請(qǐng)與我們聯(lián)系,我們將在24小時(shí)內(nèi)進(jìn)行處理、任何非本站因素導(dǎo)致的法律后果,本站均不負(fù)任何責(zé)任。

聯(lián)系QQ:835971066 | 郵箱:835971066#qq.com(#換成@)

Copyright © 2002-2020 腳本教程網(wǎng) 版權(quán)所有