Javascript Datatable中有2个页脚行,1个用于筛选器,1个用于汇总行
我正试图在我的表2页脚行的bootom处设置。I表示过滤器,另一个表示总和。它是分开工作的,但不是一起工作的。谢谢你的帮助。 我怀疑方法“.footer()”试图在页脚的第一行显示值Javascript Datatable中有2个页脚行,1个用于筛选器,1个用于汇总行,javascript,jquery,filter,sum,footer,Javascript,Jquery,Filter,Sum,Footer,我正试图在我的表2页脚行的bootom处设置。I表示过滤器,另一个表示总和。它是分开工作的,但不是一起工作的。谢谢你的帮助。 我怀疑方法“.footer()”试图在页脚的第一行显示值 <table id="vydana_faktura_seznam" class="table table-striped table-bordered dt-responsive nowrap"> <thead> <tr>
<table id="vydana_faktura_seznam" class="table table-striped table-bordered dt-responsive nowrap">
<thead>
<tr>
<th>ID</th>
<th>ICO</th>
<th>Jmeno spolecnosti</th>
<th>Datum vystaveni</th>
<th dt:sortInitDirection="asc">Datum splatnosti</th>
<th>Spedice</th>
<th>SPZ</th>
<th>VS</th>
<th>Castka</th>
<th>Mena</th>
<th>Vystavil</th>
<th>Zaplacena</th>
</tr>
</thead>
<tfoot>
<!-- search row -->
<tr>
<th />
<th />
<th />
<th />
<th />
<th />
<th />
<th />
<th />
<th />
<th />
<th />
</tr>
<!-- summ row -->
<tr>
<td />
<td />
<td />
<td />
<td />
<td />
<td />
<td />
<td class="footer_summ" style="text-align: right; padding: 8px 10px"></td>
<td />
<td />
<td />
</tr>
</tfoot>
<script type="text/javascript">
$('#vydana_faktura_seznam tfoot tr:eq(0) th').each( function () {
var title = $(this).text();
$(this).html( '<input type="text" placeholder="Hledej '+title+'" style="width:100%" />' );
} );
// DataTable
var table = $('#vydana_faktura_seznam').DataTable();
// Apply the search
table.columns().every( function () {
var that = this;
$( 'input', this.footer() ).on( 'keyup change', function () {
if ( that.search() !== this.value ) {
that
.search( this.value )
.draw();
}
} );
} );
</script>
<script type="text/javascript">
$('#vydana_faktura_seznam').DataTable( {
"footerCallback" : function ( data ) {
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
var total = api
.column( 8 )
.data()
.reduce( function (a, b) {
return intVal(a) + intVal(b);
}, 0 );
// Total over this page
var pageTotal = api
.column( 8, { page: 'current'} )
.data()
.reduce( function (a, b) {
return intVal(a) + intVal(b);
}, 0 ).toFixed(2);
// Update footer
$( api.column( 8 ).footer() ).html(
pageTotal
);
}
} );
</script>
身份证件
ICO
斯波莱克诺斯蒂酒店
维斯塔维尼基准面
基准splatnosti
斯佩迪奇
SPZ
VS
卡斯特卡
中东和北非
维斯塔维尔
扎普拉塞纳
$('vydana_faktura_seznam tfoot tr:eq(0)th')。每个(函数(){
var title=$(this.text();
$(this.html(“”);
} );
//数据表
var表=$('vydana_faktura_seznam')。数据表();
//应用搜索
table.columns().every(函数(){
var=这个;
$('input',this.footer()).on('keyup change',函数(){
如果(that.search()!==this.value){
那个
.search(this.value)
.draw();
}
} );
} );
$('vydana_faktura_seznam')。数据表({
“footerCallback”:函数(数据){
var api=this.api(),数据;
//删除格式以获取求和的整数数据
var intVal=函数(i){
返回typeof i=='string'?i.replace(/[]/g',)*1:typeof i=='number'?i:0;
};
//总页数
var总计=api
.第(8)栏
.data()
.减少(功能a、b){
返回intVal(a)+intVal(b);
}, 0 );
//本页总计
var pageTotal=api
.column(8,{page:'current'})
.data()
.减少(功能a、b){
返回intVal(a)+intVal(b);
}toFixed(2);
//更新页脚
$(api.column(8.footer()).html(
页面总数
);
}
} );
最后,我通过这里的帮助解决了我的问题