How to determine number of rows in a table
How to determine number of rows in a table
alextang
Posts: 9Questions: 2Answers: 0
I have searched many places, but were unable to find a solution. I wanted to have a way to find out the number of table rows after a Ajax call.
I see the followings in some posts
oTable.fnSettings().fnRecordsTotal()
oTable.fnGetData().length
but, they did not seem to work. Not sure if they are obsolete or not (i.e Hungarian notation).
If I have
var table = $(#example).dataTable();
alert(table.fnGetData().length) does not seem to work. I am using the datatables 1.10.1.
Thanks,
Alex
This discussion has been closed.
Answers
Those are old calls, that doesn't mean they're obsolete, just that you have to use the new syntax if that's what you are using elsewhere. Gotta be consistent on the syntax you're using otherwise things wont work properly.
I think what you're looking for is
found at http://datatables.net/reference/api/page.info()
Rpiechura, this does not work for me as I used Ajax. I wanted to get the row number after the Ajax. Ideally, some type of event when Ajax is done.
Not sure if this is the best approach. But, it works
$("#install-finished-datatable").dataTable({
}).on('draw.dt', function ( e, settings, json ) {
$('#badge-finished').html($('#install-finished-datatable tbody tr').length);
});
find the answer,
page.info().recordsTotal
is the correct way.