这几天做权限管理的时候 权限列表的展示 用到了这个插件 也是好一番研究之后才会用 现在想想其实挺简单的 主要就是js的配置
<!DOCTYPE html>
<HTML>
<HEAD>
<TITLE> ZTREE DEMO - getChangeCheckedNodes / getCheckedNodes</TITLE>
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<link rel="stylesheet" href="__PUBLIC__/plugin/ztree/css/zTreeStyle/zTreeStyle.css" type="text/css">
<script type="text/javascript" src="__PUBLIC__/js/jquery-1.7.2.js"></script>
<script type="text/javascript" src="__PUBLIC__/plugin/ztree/js/jquery.ztree.core.min.js"></script>
<script type="text/javascript" src="__PUBLIC__/plugin/ztree/js/jquery.ztree.excheck.min.js"></script>
<SCRIPT type="text/javascript">
<!--
var setting = {
view: {
selectedMulti: false
},
check: {
enable: true,
//chkStyle: "radio", 这两个是单选用
//radioType: "all"
},
data: {
simpleData: {
enable: true
}
},
callback: {
onCheck: onCheck
}
};
var zNodes =[
{ id:1, pId:0, name:"随意勾选 1", open:true},
{ id:11, pId:1, name:"随意勾选 1-1"},
{ id:12, pId:1, name:"随意勾选 1-2", open:true},
{ id:121, pId:12, name:"随意勾选 1-2-1", checked:true},
{ id:122, pId:12, name:"随意勾选 1-2-2"},
{ id:123, pId:12, name:"随意勾选 1-2-3"},
{ id:13, pId:1, name:"随意勾选 1-3"},
{ id:2, pId:0, name:"随意勾选 2", open:true},
{ id:21, pId:2, name:"随意勾选 2-1"},
{ id:22, pId:2, name:"随意勾选 2-2", open:true},
{ id:221, pId:22, name:"随意勾选 2-2-1", checked:true},
{ id:222, pId:22, name:"随意勾选 2-2-2"},
{ id:223, pId:22, name:"随意勾选 2-2-3"},
{ id:23, pId:2, name:"随意勾选 2-3", checked:true}
];
var clearFlag = false;
function onCheck(e, treeId, treeNode) {
}
$(document).ready(function(){
$.fn.zTree.init($("#treeDemo"), setting, zNodes);
});
function print_rez(){
var zTree = $.fn.zTree.getZTreeObj("treeDemo");
nodes = zTree.getCheckedNodes();
var total_nodes='';
$(nodes).each(function(i,val){
total_nodes=total_nodes+val.id+',';
});
$('#print').html(total_nodes);
}
//-->
</SCRIPT>
</HEAD>
<BODY>
<h1>checkbox 勾选统计</h1>
<h6>[ 文件路径: excheck/checkbox_count.html ]</h6>
<div>
<ul id="treeDemo" class="ztree"></ul>
<button onclick="print_rez()">提交</button>
<div id="print"></div>
</div>
</BODY>
</HTML>
链接:http://pan.baidu.com/s/1bRViPK 密码:wvgz