码迷,mamicode.com
首页 > 其他好文 > 详细

160418、ztree权限菜单

时间:2016-04-19 17:35:25      阅读:237      评论:0      收藏:0      [点我收藏+]

标签:

1、页面中引用ztree的css和js(大家自行下载ztree)

<link rel="stylesheet" href="${ctx}/resources/js/plugins/ztree/zTreeStyle/demo.css" type="text/css">
<link rel="stylesheet" href="${ctx}/resources/js/plugins/ztree/zTreeStyle/zTreeStyle.css" type="text/css">
<script type="text/javascript" src="${ctx}/resources/js/plugins/ztree/jquery-1.4.4.min.js"></script>
<script type="text/javascript" src="${ctx}/resources/js/plugins/ztree/jquery.ztree.core-3.5.js"></script>
<script type="text/javascript" src="${ctx}/resources/js/plugins/ztree/jquery.ztree.excheck-3.5.js"></script>

2、javascript

<script type="text/javascript">
var setting = {
/* check: {
enable: true
}, */
data: {
simpleData: {
enable : true,
idKey : "id",
pIdKey : "pId",
rootPId : "0"
}
},
callback : {
onClick : function(event, treeId, treeNode, clickFlag) {
if (treeNode.murl) {
var url = "${appctx}" + treeNode.murl;
document.getElementById("mainFrame").src = url;
}
}
}
};

var zNodes;

$(document).ready(function(){
$.ajax({
url : "${appctx}/menu/getMenuData.action",
type : "post",
dataType : "json",
async : false,
success : function(datas){
zNodes = datas;
}
});
$.fn.zTree.init($("#treeDemo"), setting, zNodes);
});
</script>

3、body中添加div

<div id="treeDemo" class="ztree"></div>

 

注:后台返回的json数据

[{id:1, pId:0, name:"系统设置",open:true},{id:11, pId:1, name:"菜单管理"},{id:12, pId:1, name:"角色管理"},{id:13, pId:1, name:"人员管理"}];

160418、ztree权限菜单

标签:

原文地址:http://www.cnblogs.com/zrbfree/p/5408694.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!