Skip to content

Commit bbd9e2e

Browse files
committed
Add footer formatter to print example
1 parent 6c428f3 commit bbd9e2e

1 file changed

Lines changed: 6 additions & 1 deletion

File tree

extensions/print.html

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
<table
1717
id="table"
1818
data-show-print="true"
19+
data-show-footer="true"
1920
data-url="json/data1.json"
2021
>
2122
<thead>
@@ -26,7 +27,7 @@
2627
<th data-field="name">
2728
Item Name
2829
</th>
29-
<th data-field="price">
30+
<th data-field="price" data-footer-formatter="priceFormatter">
3031
<i class="fa fa-print"></i> Item Price
3132
</th>
3233
</tr>
@@ -42,4 +43,8 @@
4243
printStyles: ['https://cdn.jsdelivr.net/npm/@fortawesome/fontawesome-free@6.5.2/css/all.min.css']
4344
})
4445
}
46+
47+
function priceFormatter (data) {
48+
return '$' + data.reduce((sum, item) => sum + parseFloat(item.price.replace('$', '')), 0)
49+
}
4550
</script>

0 commit comments

Comments
 (0)