I have been trying to get the row count of my table after filtering, but I can't even get it to respond back with the row count initially.
My table is rendered via HTML5 and populated by PHP which all works correctly.
<table id="table_books" class="table datatable" data-searchplaceholder="Search books..." data-margindifference="70" >
<thead>
<tr>
<th style="width:30px;"><i class="fa fa-code" title="click"></i></th>
<th>Column1</th>
<th>Column2</th>
<th>Column3</th>
<th class="text-right hidden-xs" style="width:20%">Details</th>
</tr>
</thead>
<tbody>
<?php echo $contenthtml; ?>
</tbody>
</table>
I found documentation that says this works in 1.9, but I get an invalid function
$(document).ready(function() {
var btable = $('#table_books').DataTable();
var b_table_count = btable._('tr', {"filter":"applied"});
console.log(b_table_count);
});
Use page.info()
API method to get paging information about the table.
It returns an object, for example:
{
"page": 1,
"pages": 6,
"start": 10,
"end": 20,
"length": 10,
"recordsTotal": 57,
"recordsDisplay": 57
}
Usage:
function getNumFilteredRows(id){
var info = $(id).DataTable().page.info();
return info.recordsDisplay;
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With