html:
<link href="vendors/zTreeStyle/zTreeStyle.css" rel="stylesheet" />
生态系统类型* :
<asp:TextBox ID="TextBox3" CssClass="form-control" runat="server" MaxLength="200" autocomplete="off"></asp:TextBox>
<ul class=" dropdown-menu">
<li>
<ul class="ztree " id="ecosystemType"></ul>
</li>
<li class="ddl_close"><span>关闭</span></li>
</ul>
<script src="vendors/zTreeStyle/jquery-migrate-1.2.1.js"></script>//ztree 与jquery 版本兼容
<script src="vendors/zTreeStyle/jquery.ztree.core-3.4.js"></script>
<script src="vendors/zTreeStyle/jquery.ztree.excheck-3.4.js"></script>
<script src="vendors/bower_components/angular/angular.min.js"></script>
js:
jQuery(document).ready(function($) {
//点击输入框的 显示下拉框
$(".form-control").click(function() {//alert( $(this).find(".ddl_close").html());
$(this).next(".dropdown-menu").show()
$("body").bind("mousedown", onBodyDown);
})
function hideMenu() {
$(".dropdown-menu").fadeOut("fast");
$("body").unbind("mousedown", onBodyDown);
//点击其他位置 关闭下拉
function onBodyDown(event) {
if (!(event.target.id == "dropdown-menu" || $(event.target).parents(".dropdown-menu").length > 0)) {
hideMenu();
}
}
//关闭下来
$(".ddl_close").click(function() {
$(this).parent(".dropdown-menu").hide();
})
})
//-------------angular controller----js------------------------------------------
var app=angular.module('myApp',[]);
app.controller('news_Ctrl',function($scope,$http,$rootScope) {
//绑定 生态系统类型
$scope.setting_ecosystemType={//树形基本配置
check: {enable: true,},
view: {showIcon: false},
data: {simpleData: {enable: true}},
callback: {onCheck: onCheck_ecosystemType}
};
function onCheck_ecosystemType(e,treeId,treeNode) {//点击复选框触发事件
var zTree=$.fn.zTree.getZTreeObj(treeId);
nodes=zTree.getCheckedNodes(true);
var v="";
for(var i=0,l=nodes.length;i<l;i++) {
if(nodes[i].isParent==false)
{ v+=nodes[i].name+",";}//记录底层勾选的集树,不记录父级
}
if(v.length>0) v=v.substring(0,v.length-1); //去掉最后一个分隔符逗号,
$("#TextBox3").attr("value",v); //赋值到输入框TextBox3里
}
$http({
method: 'post',
url: 'WebService/ddltreeWebService.asmx/getDllTree_by_ddlNameEn', //树形的数据地址
dataType: "json",
contentType: "application/json",
data: { ddlNameEn: "ecosystemType" },//
}).then(function successCallback(response) {
var data = JSON.parse(response.data.d);//格式化json
$scope.ecosystemTypeList=data; //赋值给angular变量 // console.log($scope.ecosystemTypeList);输出测试
for (i = $scope.ecosystemTypeList.length - 1; i >= 0; i--) {
$scope.ecosystemTypeList[i].open=true;//默认展开树
}
$.fn.zTree.init($("#ecosystemType"),$scope.setting_ecosystemType,$scope.ecosystemTypeList); //生成树
});
});
免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。