[英]How to add multiple row in bootstrap-table footer?
您可以通過使用 jQuery DataTable 插件來實現這一點。 它有類似的例子here
首先,將此添加到您的表中,
<tfoot>
<tr>
<th colspan="6" class="text-right">Total: </th>
<th colspan="2"></th>
</tr>
</tfoot>
然后添加以下腳本:
$('.tableClassor#tableID').DataTable({
dom: '<"top">rt<"bottom"lfp><"clear">',
footerCallback: function (row, data, start, end, display) {
var api = this.api(), data;
//Remove the formatting to get integer data for summation
var intVal = function (i) {
return typeof i === 'string' ?
i.replace(/[$,]/g, '')*1 :
typeof i === 'number' ?
i : 0;
};
//Total over all pages,
total = api
.column( 6 )
.data()
.reduce( function (a, b) {
return intVal(a) + intVal(b);
}, 0);
//Total over this page
pageTotal = api
.column( 6, {page: 'current'})
.data()
.reduce(function (a, b) {
return intVal(a) + intVal(b);
}, 0 );
//Update footer
$(api.column( 6 ).footer() ).html(
'$ '+pageTotal +' ( $ '+ total +' total )'
);
}
})
調整colspan
值以使總計與要統計的列對齊。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.