Repository navigation
Expand file tree
/
Copy pathfilter-options.html
More file actions
86 lines (78 loc) · 1.68 KB
/
Copy pathfilter-options.html
File metadata and controls
86 lines (78 loc) · 1.68 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
<script>
init({
title: 'Filter Options',
desc: 'Use `filterOptions` option to define the default filter options of algorithm. In this case, we are using `bootstrapTable(\'filterBy\', {id: 3, price: \'$1\'})`.',
links: ['bootstrap-table.min.css'],
scripts: ['bootstrap-table.min.js']
})
</script>
<style>
#select {
width: 100px;
display: inline-block;
}
</style>
<div class="toolbar">
<select id="select" class="form-control" name="filterAlgorithm">
<option value="and" selected>and</option>
<option value="or">or</option>
</select>
<button class="btn btn-secondary" id="filterBy">filterBy</button>
</div>
<table id="table">
</table>
<script>
var $table = $('#table')
function mounted() {
$table.bootstrapTable({
toolbar: '.toolbar',
columns: [{
title: 'ID',
field: 'id'
}, {
title: 'Item Name',
field: 'name'
}, {
title: 'Item Price',
field: 'price'
}],
data: [{
id: 1,
name: 'Item 1',
price: '$1'
},
{
id: 2,
name: 'Item 2',
price: '$2'
},
{
id: 3,
name: 'Item 3',
price: '$1'
},
{
id: 4,
name: 'Item 4',
price: '$4'
},
{
id: 5,
name: 'Item 5',
price: '$5'
}]
})
$('#filterBy').click(function () {
var filterAlgorithm = $('[name="filterAlgorithm"]').val()
$table.bootstrapTable('refreshOptions', {
filterOptions: {
filterAlgorithm: filterAlgorithm
}
})
$table.bootstrapTable('filterBy', {
id: 3,
price: '$1'
})
})
}
</script>