javascript - jQuery jTable 分页无法正常工作

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

我在基于 Web 的项目中使用 jquery jTable。当行数小于 10,000 时,它的分页工作正常。但是,当行数超过 10000 时,它会导致分页出现不熟悉的问题。分页开始跳过奇数页编号。您可以在下图中看到它:enter image description here

我的 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) {

            }
        });

而我的 jTablehtml 标记是:

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

我探索了很多\,但没有找到与之相关的解决方案。我更无法理解这种失误行为。

最佳答案

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

_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
}

您只需对上面给出的函数的这部分进行注释,或者根据您自己的实现逻辑进行修改即可。

在我上面提到的案例中,我的 no_of_pages 从 1000 开始增加,这就是为什么它需要更改页面的 2 个步骤等等。

关于javascript - jQuery jTable 分页无法正常工作,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42387751/

相关文章:

javascript - 如何使用 React 的上下文功能将 HTML5 Canvas 上下文传递给 this.props.children?

javascript - 需要添加日期

javascript - 了解函数中 mouseenter 链接的类

c# - 上传图片asp.net Core

c# - mefcontrib拦截目录导出错误

javascript - LocalStorage 在警报 block 期间未更新

javascript - 从 1 d3.select 隐藏另一个 div

jquery - 带有背景位置放置难题的高级 css sprite 菜单

javascript - 如何同时在多个 div 上运行一个函数?

c# - 无法使用jquery从 Controller 获取数据