2014-02-08 55 views
0

我有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的分頁。

如何保持此分頁仍顯示頁面/總頁數?

+0

原始問題的一些示例或鏈接將有所幫助 –

回答

0
totalRatio = (iTotal/perPage !== iTotal/perPage) ? 0 : iTotal/perPage; 
//.. 
currentRatio = (iStart/perPage !== iStart/perPage) ? 0 : iStart/perPage; 
+0

Hi @chiliNut,現在插入你的代碼後,它的Nan/0?任何線索? –

+0

'perPage =((iEnd - iStart + 1> 0)?(iEnd-iStart + 1):1)' – chiliNUT

+0

完美,非常感謝 –

相關問題