I'm searching my datatable
with the following statement:
var dataTable = $(#dt).DataTable().search("searchpattern");
dataTable.draw();
So everything is fine and the datatable is just showing entries that matchs to the searchpattern.
But how i can determine, how many entries are matching to the pattern?
I've tried the following:
dataTable.rows().nodes().length;
but returned is always the number of all records and not the count of matching records. Thanks for your help in advise!
You can use this, as per get filtered rows:
dataTable.$('tr', {"filter":"applied"}).length;
Since DataTables 1.10 , using dataTable.page.info()
looks the best way to get current info (after processing/ search/ reload).
So..
var table = $('#example').DataTable();
var info = table.page.info();
console.log(info);
result :
{
"page": 1,
"pages": 6,
"start": 10,
"end": 20,
"length": 10,
"recordsTotal": 57,
"recordsDisplay": 57,
"serverSide": false
}
info.recordsDisplay
is what you asking for. ref: page.info() at dataTables API.
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