【发布时间】:2016-04-25 13:55:30
【问题描述】:
我在显示数据表中某些列的总和时遇到问题。一个问题是我的表是动态创建的,即用户选择要显示的列,因此列索引不固定!
其次,添加代码时的 footerCallback 抛出 ncaught TypeError: Cannot read property 'nTf' of undefined error
<tfoot>
<tr>
<td colspan='2'> <span style="float:right;"id ='totalcol1'></span> </td>
</tr>
</tfoot>
FooterCAllback 在 var table=('#mytable').Datatable() 中定义
"footerCallback": function ( row, data, start, end, display ) {
var api = this.api(), data;
$(api.column(11).footer()).html(
api.column(11).data().reduce( function ( a, b ) { return a + b;})
);
/* For second column
$(api.column(12).footer()).append(
api.column(12).data().reduce( function ( a, b ) { return a + b;})
);*/
},
【问题讨论】:
标签: datatable datatables