-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
/
Copy path563.html
59 lines (54 loc) · 1.12 KB
/
563.html
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
<script>
init({
title: 'Issue #563',
desc: 'Change the background color on selected rows (<a href="https://github.com/wenzhixin/bootstrap-table/issues/563" target="_blank">#563</a>).',
links: ['bootstrap-table.min.css'],
scripts: ['bootstrap-table.min.js']
})
</script>
<script>
const $table = $('#table')
let selectedRow = {}
function mounted () {
$table.on('click-row.bs.table', function (e, row, $element) {
selectedRow = row
$('.active').removeClass('active')
$($element).addClass('active')
})
}
window.rowStyle = row => {
if (row.id === selectedRow.id) {
return {
classes: 'active'
}
}
return {}
}
</script>
<template>
<table
id="table"
data-toggle="table"
data-url="json/data1.json"
data-show-refresh="true"
data-pagination="true"
data-row-style="rowStyle"
>
<thead>
<tr>
<th data-field="name">
Item Name
</th>
<th data-field="price">
Item Price
</th>
</tr>
</thead>
</table>
</template>
<style>
.active td {
color: red;
font-weight: bold;
}
</style>