首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >未找到结果时显示NaN/NaN jQuery数据表

未找到结果时显示NaN/NaN jQuery数据表
EN

Stack Overflow用户
提问于 2014-02-08 05:39:16
回答 1查看 1K关注 0票数 0

我从另一个问题中得到了jQuery数据表函数。以下是功能:

代码语言:javascript
运行
复制
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的分页。

如何保持此分页仍显示页/总页码?

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2014-02-08 05:48:47

代码语言:javascript
运行
复制
totalRatio = (iTotal/perPage !== iTotal/perPage) ? 0 : iTotal/perPage;
//..
currentRatio = (iStart/perPage !== iStart/perPage) ? 0 : iStart/perPage;
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/21642428

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档