Hi guys, i am tyring to print the row count of datatables in the footer very first column.
$(document).ready(function() {
//data table
var table = $('#example').DataTable( {
"dom": 'Bfrtip',
"buttons" : [
{
extend: 'print',
exportOptions: {
columns: [0, 1, 2, 3, 4, 5, 6, 7, 8, 10, 11, 12, 13, 14, 15,16 ]
}
},
{
extend: 'excel',
exportOptions: {
columns: [0, 1, 2, 3, 4, 5, 6, 7, 8, 10, 11, 12, 13, 14, 15,16 ]
}
},
{
extend: 'pageLength'
}
],
"aaSorting": [[0, 'desc']],
"pageLength": 100,
"processing": false,
"bInfo": false,
"footerCallback": function ( row, data, start, end, display ) {
var api = this.api(), data;
$( api.column( 0 ).footer() ).html(table.data().length);
},
"ajax":"data.php"
});
});
now when page loads it shows error
Uncaught TypeError: Cannot read property ‘data’ of undefined
at jQuery.fn.init.footerCallback (view.php:352)
at jquery.dataTables.min.js:75
at Function.map (jquery.js:451)
at r (jquery.dataTables.min.js:75)
at N (jquery.dataTables.min.js:30)
at S (jquery.dataTables.min.js:31)
at ga (jquery.dataTables.min.js:48)
at e (jquery.dataTables.min.js:92)
at HTMLTableElement. (jquery.dataTables.min.js:92)
at Function.each (jquery.js:362)
and if i remove this part datatable works perfectly. but i need the row count.
"footerCallback": function ( row, data, start, end, display ) {
var api = this.api(), data;
$( api.column( 0 ).footer() ).html(table.data().length);
},