关于ztree创建

来源:互联网 发布:索尼kdl60w600b装软件 编辑:程序博客网 时间:2024/06/05 04:32
<script >
var treeNodes;//这里需要传一个json对象
$.ajax({
url:"${ctx}/collection/category/getTree",
dataType: "json",
async:false,
success:function(date){
jsonstr=JSON.stringify(date); //将返回的list集合转换为json字符串
treeNodes=$.parseJSON( jsonstr ); //将json字符串转换为json对象

},
error:function(){
alert("传值有误");
}
});
var setting = {

showLine : true, //是否显示节点间的连线
data: {
simpleData: {
enable: true,
idKey: "cate_id",//设置自身id
pIdKey: "cate_parent_id",//设置父节点id
rootPId: 0
},
key:{
name:"cate_name"//设置名称

}
}
};

var zTree;
$(function() {
$('.row>[class*="col-"]').eqHeights({parentSelector:'.row'});
$(".slimScrollDiv").height($('.form-groupz').height()-75);
$(".scroller").height($(".slimScrollDiv").height());
zTree = $.fn.zTree.init($("#resTree"), setting, treeNodes);
});
</script>
0 0
原创粉丝点击