首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >TableSorter寻呼机(JQuery)的分页错误

TableSorter寻呼机(JQuery)的分页错误
EN

Stack Overflow用户
提问于 2018-04-19 21:28:25
回答 1查看 314关注 0票数 1

我的一个表的分页是错误的: TableSorter分页器( jQuery )有5行,而有7行。我在另一个有相同代码的表上也有同样的问题(请参见下面):jQuery有6行,而只有3行。有人知道吗?

下面是代码(只有Javascript):

代码语言:javascript
运行
复制
$(function () {
            $('#actions_table').tooltip({
                selector: "button[data-toggle=tooltip]"
            });

            var table = $('table').tablesorter({
                theme: 'bootstrap',
                headerTemplate: '{content} {icon}',
                widgets: ["uitheme", "zebra", "filter"],
                //sortList: [[0, 1]],
                widgetOptions: {
                    // filter_anyMatch replaced! Instead use the filter_external option
                    // Set to use a jQuery selector (or jQuery object) pointing to the
                    // external filter (column specific or any match)
                    filter_external: '.search',
                    // add a default type search to the first name column
                    filter_defaultFilter: {1: '~{query}'},
                    // include column filters
                    filter_columnFilters: false,
                    filter_placeholder: {search: 'Rechercher...'},
                    filter_saveFilters: false,
                    filter_reset: '.reset'
                }
            }).tablesorterPager({
                // target the pager markup - see the HTML block below
                container: $(".pager"),
                // use this url format "http:/mydatabase.com?page={page}&size={size}" 
                ajaxUrl: null,
                // process ajax so that the data object is returned along with the
                // total number of rows; example:
                // {
                //   "data" : [{ "ID": 1, "Name": "Foo", "Last": "Bar" }],
                //   "total_rows" : 100 
                // } 
                ajaxProcessing: function (ajax) {
                    if (ajax && ajax.hasOwnProperty('data')) {
                        // return [ "data", "total_rows" ]; 
                        return [ajax.data, ajax.total_rows];
                    }
                },
                // output string - default is '{page}/{totalPages}';
                // possible variables:
                // {page}, {totalPages}, {startRow}, {endRow} and {totalRows}
                output: '{startRow} à {endRow} ({totalRows} au total)',
                // apply disabled classname to the pager arrows when the rows at
                // either extreme is visible - default is true
                updateArrows: true,
                // starting page of the pager (zero based index)
                page: 0,
                // Number of visible rows - default is 10
                size: 15,
                pageReset: 0,
                // if true, the table will remain the same height no matter how many
                // records are displayed. The space is made up by an empty 
                // table row set to a height to compensate; default is false 
                fixedHeight: false,
                savePages: false,
                // remove rows from the table to speed up the sort of large tables.
                // setting this to false, only hides the non-visible rows; needed
                // if you plan to add/remove rows with the pager enabled.
                removeRows: false,
                // css class names of pager arrows
                // next page arrow
                cssNext: '.next',
                // previous page arrow
                cssPrev: '.prev',
                // go to first page arrow
                cssFirst: '.first',
                // go to last page arrow
                cssLast: '.last',
                // select dropdown to allow choosing a page
                cssGoto: '.gotoPage',
                // location of where the "output" is displayed
                cssPageDisplay: '.pagedisplay',
                // dropdown that sets the "size" option
                cssPageSize: '.pagesize',
                // class added to arrows when at the extremes 
                // (i.e. prev/first arrows are "disabled" when on the first page)
                // Note there is no period "." in front of this class name
                cssDisabled: 'disabled'

            });
        });

EN

回答 1

Stack Overflow用户

发布于 2018-04-20 00:53:09

首先检查返回的ajax.total_rows是否正确地报告了行数。

其次,检查检查器中的HTML以验证是否存在与预期相同的行数。格式错误的超文本标记语言,或者添加第二个带行的<tbody>,也可能导致问题被报告。

票数 2
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/49922336

复制
相关文章

相似问题

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