Reputation: 204
I am working with DataTables and I need to know the current number of pages that a table holds (this certainly depends on the number of rows per page and the total number of rows and may change by user-action). Does anybody know how to access this value?
Upvotes: 4
Views: 9907
Reputation: 832
I used this for getting total number of records
"drawCallback": function( settings, start, end, max, total, pre ) {
var info = tbl_driverList.page.info();
alert(info.recordsDisplay);
}
Upvotes: 0
Reputation: 61056
I believe iTotalPages is what you're after: http://datatables.net/plug-ins/api#fnPagingInfo
$.fn.dataTableExt.oApi.fnPagingInfo = function(oSettings){
return {
"iTotalPages": oSettings._iDisplayLength === -1 ?
0 : Math.ceil( oSettings.fnRecordsDisplay() / oSettings._iDisplayLength )
};
};
$('#example').dataTable({
"fnDrawCallback": function(){
alert('There are ' + this.fnPagingInfo().iTotalPages + ' in this table.');
}
});
Upvotes: 6