3aa4c53474a8118a5395df4fa9e949bb3c2e0be1.svn-base
2.41 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
<%@ page contentType="text/html;charset=UTF-8" %>
<%@ include file="/WEB-INF/views/include/taglib.jsp"%>
<html>
<head>
<title>栏目列表</title>
<meta name="decorator" content="default"/>
<%@include file="/WEB-INF/views/include/treeview.jsp" %>
<style type="text/css">
.ztree {overflow:auto;margin:0;_margin-top:10px;padding:10px 0 0 10px;}<%--
.ztree li span.button.level0, .ztree li a.level0 {display:none;height:0;}
.ztree li ul.level0 {padding:0;background:none;}--%>
.accordion-inner{padding:2px;}
</style>
<script type="text/javascript">
$(document).ready(function(){
var setting = {view:{selectedMulti:false},data:{simpleData:{enable:true}}};
var zNodes=[
<c:forEach items="${categoryList}" var="tpl">{id:'${tpl.id}', pId:'${not empty tpl.parent?tpl.parent.id:0}', name:"${tpl.name}", url:"${ctx}/cms/${not empty tpl.module?tpl.module:'none'}/?category.id=${tpl.id}", target:"cmsMainFrame"},
</c:forEach>];
for(var i=0; i<zNodes.length; i++) {
// 移除父节点
if (zNodes[i] && zNodes[i].id == 1){
zNodes.splice(i, 1);
}<%--
// 并将没有关联关系的父节点,改为父节点
var isExistParent = false;
for(var j=0; j<zNodes.length; j++) {
if (zNodes[i].pId == zNodes[j].id){
isExistParent = true;
break;
}
}
if (!isExistParent){
zNodes[i].pId = 1;
}--%>
}
// 初始化树结构
var tree = $.fn.zTree.init($("#tree"), setting, zNodes);
// 展开第一级节点
var nodes = tree.getNodesByParam("level", 0);
for(var i=0; i<nodes.length; i++) {
tree.expandNode(nodes[i], true, true, false);
}
// 展开第二级节点
nodes = tree.getNodesByParam("level", 1);
for(var i=0; i<nodes.length; i++) {
tree.expandNode(nodes[i], true, true, false);
}
wSize();
});
$(window).resize(function(){
wSize();
});
function wSize(){
$(".ztree").width($(window).width()-16).height($(window).height()-62);
$(".ztree").css({"overflow":"auto","overflow-x":"auto","overflow-y":"auto"});
$("html,body").css({"overflow":"hidden","overflow-x":"hidden","overflow-y":"hidden"});
}
</script>
</head>
<body>
<div class="accordion-group">
<div class="accordion-heading">
<a class="accordion-toggle">栏目列表</a>
</div>
<div class="accordion-body">
<div class="accordion-inner">
<div id="tree" class="ztree"></div>
</div>
</div>
</div>
</body>
</html>