我已经创建了一个角度数据表。现在,我试图基于搜索过滤器明智地求和列,但它不起作用。我没有找到合适的解决方案。谁能指导我?预先感谢
$(document).ready(function() {
$('#example').dataTable( {
"fnFooterCallback": function ( nRow, aaData, iDataStart, iDataEnd ) {
/* Calculate the total market share for all browsers in this table (ie inc. outside
* the pagination
*/
var total = 0;
for ( var i=0 ; i<aaData.length ; i++ )
{
total+= aaData[i][8]*1;
}
/* Calculate the market share for browsers on this page */
var value = 0;
for ( var i=iDataStart ; i<iDataEnd ; i++ )
{
value += aaData[i][8]*1;
}
/* Modify the footer row to match what we want */
var nCells = nRow.getElementsByTagName('th');
nCells[1].innerHTML = parseInt(value * 100)/100 +
'% ('+ parseInt(total * 100)/100 +'% total)';
}
} );
} );