Repository navigation
Expand file tree
/
Copy pathsticky-header.html
More file actions
84 lines (76 loc) · 1.84 KB
/
Copy pathsticky-header.html
File metadata and controls
84 lines (76 loc) · 1.84 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: 'Sticky Header',
desc: 'User Plugin: bootstrap-table-sticky-header. An extension which provides a sticky header for the table when scrolling.',
links: [
'bootstrap-table.min.css',
'extensions/sticky-header/bootstrap-table-sticky-header.css'
],
scripts: [
'bootstrap-table.min.js',
'extensions/sticky-header/bootstrap-table-sticky-header.min.js'
]
})
</script>
<div class="toolbar">
<div class="radio">
<label>
<input type="radio" checked name="theadClasses">
<code>undefined</code>
</label>
</div>
<div class="radio">
<label>
<input type="radio" name="theadClasses">
<code>thead-light</code>
</label>
</div>
<div class="radio">
<label>
<input type="radio" name="theadClasses">
<code>thead-dark</code>
</label>
</div>
</div>
<table id="table" data-show-columns="true"></table>
<script>
var $table = $('#table')
function buildTable($el, cells, rows) {
var i
var j
var row
var columns = []
var data = []
for (i = 0; i < cells; i++) {
columns.push({
field: 'field' + i,
title: 'Cell' + i,
sortable: true
})
}
for (i = 0; i < rows; i++) {
row = {}
for (j = 0; j < cells; j++) {
row['field' + j] = 'Row-' + i + '-' + j
}
data.push(row)
}
var classes = $('.toolbar input:checked').next().text()
$el.bootstrapTable('destroy').bootstrapTable({
columns: columns,
data: data,
showFullscreen: true,
search: true,
stickyHeader: true,
stickyHeaderOffsetLeft: '3em',
stickyHeaderOffsetRight: '3em',
theadClasses: classes
})
}
function mounted() {
$('.toolbar input').change(function () {
buildTable($table, 20, 50)
})
buildTable($table, 20, 50)
}
</script>