Repository navigation
Expand file tree
/
Copy pathtreegrid.html
More file actions
84 lines (78 loc) · 1.98 KB
/
Copy pathtreegrid.html
File metadata and controls
84 lines (78 loc) · 1.98 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
74
75
76
77
78
79
80
81
82
83
84
<script>
init({
title: 'Treegrid',
desc: 'Use Plugin: <a href="https://github.com/maxazan/jquery-treegrid" target="_blank">jquery-treegrid</a> and bootstrap-table-treegrid.',
links: [
'https://cdnjs.cloudflare.com/ajax/libs/jquery-treegrid/0.2.0/css/jquery.treegrid.min.css',
'bootstrap-table.min.css'
],
scripts: [
'https://cdnjs.cloudflare.com/ajax/libs/jquery-treegrid/0.2.0/js/jquery.treegrid.min.js',
'bootstrap-table.min.js',
'extensions/treegrid/bootstrap-table-treegrid.min.js'
]
})
</script>
<table id="table"></table>
<script>
var $table = $('#table')
function mounted() {
$table.bootstrapTable({
url: 'json/treegrid.json',
idField: 'id',
showColumns: true,
columns: [
{
field: 'ck',
checkbox: true
},
{
field: 'name',
title: '名称'
},
{
field: 'status',
title: '状态',
sortable: true,
align: 'center',
formatter: 'statusFormatter'
},
{
field: 'permissionValue',
title: '权限值'
}
],
treeShowField: 'name',
parentIdField: 'pid',
onPostBody: function() {
var columns = $table.bootstrapTable('getOptions').columns
if (columns && columns[0][1].visible) {
$table.treegrid({
treeColumn: 1,
onChange: function() {
$table.bootstrapTable('resetView')
}
})
}
}
})
}
function typeFormatter(value, row, index) {
if (value === 'menu') {
return '菜单'
}
if (value === 'button') {
return '按钮'
}
if (value === 'api') {
return '接口'
}
return '-'
}
function statusFormatter(value, row, index) {
if (value === 1) {
return '<span class="label label-success">正常</span>'
}
return '<span class="label label-default">锁定</span>'
}
</script>