javascript - 表排序器排序和过滤不起作用

标签 javascript jquery tablesorter

我有动态表,并且使用表排序器分页器运行良好,但是当我尝试过滤某些列时,它只是将我返回到第 0 页,并且没有任何反应。在某个地方,我尝试通过单击 th 对它们进行排序,其他奇怪的事情是当我在表排序器上的输入框 Debug模式中键入时说可以。

       var $table = $(".track-grid table.tablesorter");
        var pagesize = $('.pagesize').val();
        $table.tablesorter({
            widthFixed: true,
            cssChildRow: 'infoRow',
            widgets: ['filter'],
            debug: true,
            widgetOptions: {

                filter_hideFilters: true,
                // 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_ignoreCase:false

            }

        });

        $table.on('filterInit', function () {
            $table.tablesorterPager({
                container: $(".pager"),
                ajaxUrl: `track/getEvents?page={page}&size={size}&totalCount=` + totalCount,

                customAjaxUrl: function (table, url) {
                    return url;
                },
                ajaxProcessing: function (data) {

                    $('.tablesorter tbody').html(data.result.eventsHtml);

                    $('#trackOverlay').hide();
                    return [parseInt(data.result.totalEventsCount)];
                },
                page: 0,
                processAjaxOnInit: true,
                output: '{startRow} - {endRow} / {filteredRows} ({totalRows})',
                updateArrows: true,
                fixedHeight: false,
                removeRows: false,
                savePages: false,
                cssNext: '.next',  // next page arrow
                cssPrev: '.prev',  // previous page arrow
                cssFirst: '.first', // go to first page arrow
                cssLast: '.last',  // go to last page arrow
                cssGoto: '.gotoPage', // page select dropdown - select dropdown that set the "page" option

                cssPageDisplay: '.pagedisplay', // location of where the "output" is displayed
                cssPageSize: '.pagesize', // page size selector - select dropdown that sets the "size" option
                cssDisabled: 'disabled', // Note there is no period "." in front of this class name
                cssErrorRow: 'tablesorter-errorRow' // error information row

            });
        });

最佳答案

ajaxUrl 选项需要包含一个过滤器值。如果您查看 documentation 中的示例,你会看到这个:

ajaxUrl: "http://mydatabase.com?page={page}&size={size}&{sortList:col}&{filterList:fcol}",

{filterList:fcol} 将过滤器添加到服务器请求中。

如果内置实现不适合您,请使用 customAjaxUrl callback修改ajax url。

关于javascript - 表排序器排序和过滤不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47631744/

相关文章:

javascript - 我怎样才能关注文本区域值的结尾?

javascript - 在 ng-repeat 上初始化复选框 angularjs

javascript - 未捕获的类型错误 : Cannot read property 'html' of undefined - AJAX post answer only in spesific div

javascript - 删除以前在 jQuery 中添加的元素

jQuery tablesorter 页面插件不起作用

javascript - bulma 中如何实现 affix navbar bootstrap 效果?

javascript - 更新 Svelte : Package subpath './compiler.js' is not defined by "exports" 后生成错误

javascript - 如何使用此脚本将 url 转换为超链接?

jquery - TableSort 插件问题 asp.net

javascript - Alfresco 调试器无法打开包含导入标记的 js