-
Notifications
You must be signed in to change notification settings - Fork 31
/
index.html
130 lines (125 loc) · 4.25 KB
/
index.html
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
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>TreeView-Lise</title>
<link rel="stylesheet" href="./assets/bootstrap/css/bootstrap.css">
<link rel="stylesheet" href="./assets/bootstrap-table.css">
<script src="./assets/jquery.js"></script>
<script src="./assets/bootstrap/js/bootstrap.js"></script>
<script src="./assets/bootstrap-table.js"></script>
<script src="./src/bootstraptable-treeview.js"></script>
</head>
<body>
<div style="margin:20px">
<input type="button" id="expandAllTree" value="展开所有" class="btn btn-defaul"/>
<input type="button" id="collapseAllTree" value="折叠所有" class="btn btn-defaul"/>
<table id="tree_table"></table>
</div>
<script>
$(function () {
var data = [
{
id: '1',
name: "aa",
desc: "这是一个描述",
parentId:null,
},{
id: '11',
name: "aa_sub1",
desc: "这是一个描述_sub1",
parentId:'1',
},{
id: '111',
name: "aa_sub1_sub2",
desc: "这是一个描述_sub1_sub2" ,
parentId:'11',
},
{
id: '2',
name: "bb",
desc: "这是一个描述",
parentId:null,
},
{
id: '22',
name: "bb_sub1",
desc: "这是一个描述_sub1",
parentId:'2',
},{
id: '23',
name: "bb_sub2",
desc: "这是一个描述_sub2",
parentId:'2',
},{
id: '233',
name: "bb_sub2_sub2",
desc: "这是一个描述_sub2_sub2",
parentId:'23',
},{
id: '2333',
name: "bb_sub2_sub2_sub2",
desc: "这是一个描述_sub2_sub2_sub2",
parentId:'233',
},{
id: '23333',
name: "bb_sub2_sub2_sub23",
desc: "这是一个描述_sub2_sub2_sub2",
parentId:'233',
},{
id: '233333',
name: "bb_sub2_sub2_sub233",
desc: "这是一个描述_sub2_sub2_sub2",
parentId:'233',
},{
id: '24',
name: "bb_sub3",
desc: "这是一个描述_sub3",
parentId:'2',
},
]
$('#tree_table').bootstrapTable({
class: 'table table-hover table-bordered',
url:'data.json',
contentType: 'application/x-www-form-urlencoded; charset=utf-8',
// data: data,
sidePagination: 'server',
pagination: false,
treeView: true,
treeId: "id",
treeField: "name",
rowAttributes: function (row, index) {
return {
xx:index
};
},
queryParams : function(params) {
var param = {
roleId : 'xx'
};
return param;
},
columns: [{
checkbox:true
},{
field: 'name',
title: '名称',
},
{
field: 'desc',
title: '详情',
},
]
});
$("#expandAllTree").on('click',function(){
$('#tree_table').bootstrapTable("expandAllTree")
})
$("#collapseAllTree").on('click',function(){
$('#tree_table').bootstrapTable("collapseAllTree")
})
});
</script>
</body>
</html>