Repository navigation
Expand file tree
/
Copy pathreorder-columns.html
More file actions
61 lines (56 loc) · 1.59 KB
/
Copy pathreorder-columns.html
File metadata and controls
61 lines (56 loc) · 1.59 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
<script>
init({
title: 'Reorder Columns',
desc: 'Use Plugin: <a href="https://github.com/akottr/dragtable/" target="_blank">dragtable</a> and bootstrap-table-reorder-columns.',
links: [
'https://cdn.jsdelivr.net/gh/akottr/dragtable@master/dragtable.css',
'bootstrap-table.min.css'
],
scripts: [
'https://cdnjs.cloudflare.com/ajax/libs/jqueryui/1.12.1/jquery-ui.min.js',
'https://cdn.jsdelivr.net/gh/akottr/dragtable@master/jquery.dragtable.js',
'bootstrap-table.min.js',
'extensions/reorder-columns/bootstrap-table-reorder-columns.min.js'
]
})
</script>
<div class="toolbar">
<button class="btn btn-primary" id="order1">Order by Name, ID, price</button>
<button class="btn btn-primary" id="order2">Order by Price, Name, ID</button>
</div>
<table
id="table"
data-toolbar=".toolbar"
data-show-columns="true"
data-search="true"
data-show-toggle="true"
data-pagination="true"
data-url="json/data1.json"
data-reorderable-columns="true">
<thead>
<tr>
<th data-field="id" data-sortable="true">ID</th>
<th data-field="name" data-sortable="true">Item Name</th>
<th data-field="price" data-sortable="true">Item Price</th>
</tr>
</thead>
</table>
<script>
function mounted() {
$('#table').bootstrapTable()
$('#order1').on('click', () => {
$('#table').bootstrapTable('orderColumns', {
name: 0,
id: 1,
price: 2
})
})
$('#order2').on('click', () => {
$('#table').bootstrapTable('orderColumns', {
price: 0,
name: 1,
id: 2
})
})
}
</script>