Skip to content

Commit ab8ea15

Browse files
authored
Merge pull request #582 from wenzhixin/fix/print-ignore-lint-error
Fix print extension lint errors and add row/cell styles
2 parents 887724d + b36b9c3 commit ab8ea15

2 files changed

Lines changed: 45 additions & 7 deletions

File tree

extensions/print.html

Lines changed: 30 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,11 @@
2727
<th data-field="name">
2828
Item Name
2929
</th>
30-
<th data-field="price" data-footer-formatter="priceFormatter">
30+
<th
31+
data-field="price"
32+
data-footer-formatter="priceFormatter"
33+
data-cell-style="priceStyle"
34+
>
3135
<i class="fa fa-print"></i> Item Price
3236
</th>
3337
</tr>
@@ -40,9 +44,33 @@
4044

4145
function mounted () {
4246
$table.bootstrapTable({
43-
printStyles: ['https://cdn.jsdelivr.net/npm/@fortawesome/fontawesome-free@6.5.2/css/all.min.css']
47+
printStyles: ['https://cdn.jsdelivr.net/npm/@fortawesome/fontawesome-free@6.5.2/css/all.min.css'],
48+
rowStyle (row, index) {
49+
return {
50+
css: index % 2 === 0 ? { 'font-weight': 'bold' } : {}
51+
}
52+
}
4453
})
4554
}
4655

4756
window.priceFormatter = data => `$${data.reduce((sum, item) => sum + parseFloat(item.price.replace('$', '')), 0)}`
57+
58+
window.priceStyle = function (value) {
59+
const price = parseFloat(value.replace('$', ''))
60+
61+
if (price >= 15) {
62+
return {
63+
css: { 'background-color': '#d4edda', color: '#155724', 'font-weight': 'bold' }
64+
}
65+
}
66+
if (price >= 7) {
67+
return {
68+
css: { 'background-color': '#fff3cd', color: '#856404', 'font-weight': 'bold' }
69+
}
70+
}
71+
return {
72+
css: { 'background-color': '#f8d7da', color: '#721c24', 'font-weight': 'bold' }
73+
}
74+
}
4875
</script>
76+

options/buttons-order.html

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,21 @@
1515

1616
<template>
1717
<ul id="sortable">
18-
<li data-value="fullscreen">fullscreen</li>
19-
<li data-value="paginationSwitch">paginationSwitch</li>
20-
<li data-value="refresh">refresh</li>
21-
<li data-value="toggle">toggle</li>
22-
<li data-value="columns">columns</li>
18+
<li data-value="fullscreen">
19+
fullscreen
20+
</li>
21+
<li data-value="paginationSwitch">
22+
paginationSwitch
23+
</li>
24+
<li data-value="refresh">
25+
refresh
26+
</li>
27+
<li data-value="toggle">
28+
toggle
29+
</li>
30+
<li data-value="columns">
31+
columns
32+
</li>
2333
</ul>
2434

2535
<table

0 commit comments

Comments
 (0)