totalRatio = (iTotal/perPage !== iTotal/perPage) ? 0 : iTotal/perPage;
//..
currentRatio = (iStart/perPage !== iStart/perPage) ? 0 : iStart/perPage;
displaying NaN/NaN when result was not found jQuery data tables
-
08-10-2022 - |
문제
I have jQuery data tables function I get from another question on SO. Here is the function:
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 + ' ';
}
});
This function is to displaying page/totalpage on pagination. But when I do search on search box, with no record inside the table, the pagination displaying NaN/Nan.
How to keep this pagination still displaying page/totalpage number?
해결책
제휴하지 않습니다 StackOverflow