我有jQuery數據表函數我從另一個問題得到的SO。這裏是功能:當沒有找到結果時顯示NaN/NaN 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 + ' ';
}
});
此功能是顯示分頁頁面/ totalpage。但是當我在搜索框上進行搜索時,表格中沒有記錄,顯示NaN/Nan的分頁。
如何保持此分頁仍顯示頁面/總頁數?
原始問題的一些示例或鏈接將有所幫助 –