【问题标题】:jQuery jTable pagination is not working properlyjQuery jTable 分页无法正常工作
【发布时间】:2017-07-12 06:45:38
【问题描述】:

我在基于 Web 的项目中使用 jquery jTable。当行数少于 10,000 时,它的分页工作正常。但是当行数超过10000时,会导致分页出现不熟悉的问题。分页开始跳过奇数页码。如下图所示:

jTablejavaScript 代码是:

$("#AllProductTable").jtable({
            paging: true,
            pageSize: 10,
            columnSelectable: false,
            actions: {
                listAction: '/ProductDefinition/Select'
            },
            fields: {
                ProductId: { visibility: 'hidden', listClass: 'right-align' },
                ProductCode: { title: 'Product Code' }, 
                // more fields...
            },
            recordsLoaded: function (event, data) {

            }
        });

而我的html jTable 标签是:

 <div id="AllProductTable" style="width:400%;"></div>

我探索了很多\,但没有找到与之相关的解决方案。我进一步无法理解这种错过行为。

【问题讨论】:

    标签: javascript jquery asp.net-mvc pagination jquery-jtable


    【解决方案1】:

    最后,我成功地解决了这个问题。我浏览了jquery.jtable.js 整个文件,并在其中一个function 中发现了一些奇怪的东西。函数是;

    _refreshGotoPageInput: function() {
        // different logic statements 
        //...
    
        //Skip some pages is there are too many pages
        var pageStep = 1;
        if (currentPageCount > 10000) {       // if you having  more than 10,000 pages
           pageStep = 100;
        } else if (currentPageCount > 5000) {  // if you having  more than 5000 pages
             pageStep = 10;
        } else if (currentPageCount > 2000) {  // if you having  more than 2000 pages
             pageStep = 5;
        } else if (currentPageCount > 1000) {  // if you having  more than 1000 pages 
             pageStep = 2;
        }
    
        //....
        // Differnet logic statements
    }
    

    你只需要comment上面给出的function这部分,或者根据自己的实现逻辑进行修改。

    在我上面提到的情况下,我的 no_of_pages 从 1000 增加,这就是为什么它采取 2-steps on changes page 等等。

    【讨论】:

      猜你喜欢
      • 2013-12-14
      • 2014-09-21
      • 2013-08-22
      • 2012-09-25
      • 2016-07-29
      • 2017-11-27
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多