我从另一个问题中得到了jQuery数据表函数。以下是功能:
var oTable = $('#test').dataTable( {
"aoColumnDefs": [
{ "bSortable": false, "aTargets": [ 0 ] }
],
"aaSorting": [[1, 'asc']],
"iDisplayLength": 1,
"bInfo": true,
"fnInfoCallback": function( oSettings, iStart, iEnd, iMax, iTotal, sPre ) {
perPage = iEnd - iStart + 1;
totalRatio = iTotal/perPage;
intTotalRatio = parseInt(totalRatio, 10);
totalPages = totalRatio > intTotalRatio ? intTotalRatio + 1 : intTotalRatio;
currentRatio = iStart/perPage;
intCurrentRatio = parseInt(currentRatio, 10);
currentPage = currentRatio > intCurrentRatio ? intCurrentRatio + 1 : intCurrentRatio;
return ' ' + currentPage + ' / ' + totalPages + ' ';
}
});
此功能是在分页上显示页/总页。但是,当我在搜索框中搜索时,在表中没有记录时,显示NaN/Nan的分页。
如何保持此分页仍显示页/总页码?
发布于 2014-02-08 05:48:47
totalRatio = (iTotal/perPage !== iTotal/perPage) ? 0 : iTotal/perPage;
//..
currentRatio = (iStart/perPage !== iStart/perPage) ? 0 : iStart/perPage;
https://stackoverflow.com/questions/21642428
复制相似问题