Repository navigation
Expand file tree
/
Copy pathfixed-columns.html
More file actions
117 lines (107 loc) · 2.61 KB
/
Copy pathfixed-columns.html
File metadata and controls
117 lines (107 loc) · 2.61 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
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
<script>
init({
title: 'Fixed Columns',
desc: 'Use Plugin: bootstrap-table-fixed-columns to enable the fixed columns feature.',
links: [
'bootstrap-table.min.css',
'extensions/fixed-columns/bootstrap-table-fixed-columns.css'
],
scripts: [
'bootstrap-table.min.js',
'extensions/fixed-columns/bootstrap-table-fixed-columns.js'
]
})
</script>
<div>
<button id="button" class="btn btn-secondary">Show Row</button>
<button id="button2" class="btn btn-secondary">Hide Row</button>
</div>
<div class="toolbar form-inline">
<span>Fixed Number: </span>
<input class="form-control" id="fixedNumber" type="number" value="2" min="1" max="5">
</div>
<table id="table" data-height="400" data-show-columns="true"></table>
<script>
var $table = $('#table')
function buildTable($el, cells, rows) {
var i
var j
var row
var columns = [{
field: 'state',
checkbox: true,
rowspan: 2,
valign: 'middle'
}]
var data = []
for (i = 0; i < cells; i++) {
columns.push({
field: 'field' + i,
title: 'Cell' + i,
sortable: true,
rowspan: 2,
valign: 'middle',
formatter: function (val) {
return '<div class="item">' + val + '</div>'
},
events: {
'click .item': function () {
console.log('click')
}
}
})
}
for (i = 0; i < rows; i++) {
row = {}
for (j = 0; j < cells + 3; j++) {
row['field' + j] = 'Row-' + i + '-' + j
}
data.push(row)
}
columns.push({
title: 'More Cells',
colspan: 3,
align: 'center'
})
$el.bootstrapTable('destroy').bootstrapTable({
columns: [columns, [{
field: 'field' + cells,
title: 'Cells' + cells,
sortable: true,
align: 'center'
}, {
field: 'field' + (cells + 1),
title: 'Cells' + (cells + 1),
sortable: true,
align: 'center'
}, {
field: 'field' + (cells + 2),
title: 'Cells' + (cells + 2),
align: 'center'
}]],
data: data,
search: true,
toolbar: '.toolbar',
fixedColumns: true,
fixedNumber: +$('#fixedNumber').val()
})
}
function mounted() {
buildTable($table, 20, 20)
$('#fixedNumber').change(function () {
buildTable($table, 20, 20)
})
$('#button').click(function() {
$table.bootstrapTable('showRow', {
index: 1
})
})
$('#button2').click(function() {
$table.bootstrapTable('hideRow', {
index: 1
})
})
}
</script>
</body>
</html>