本文介绍了如何获取DataTable中的页数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在使用,我需要知道表的所有页面数(这当然是取决于每页的行数和总行数,并可能由用户操作更改)。有没有人知道如何访问这个值?
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?
推荐答案
我相信iTotalPages是你之后的:
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.');
}
});
这篇关于如何获取DataTable中的页数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!