本文介绍了更新JQuery Tablesorter过滤器功能的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用最新版本的JQuery Tablesorter,并已应用过滤器"小部件.在两列中,我正在使用过滤器功能在过滤器中显示一个下拉菜单,以便用户从所有可用值中进行选择.

I am using JQuery Tablesorter, latest version, with the Filter widget applied. On two columns, I am using a filter function to display a drop-down in the filter allowing the user to select from all available values.

        widgetOptions: {
            filter_functions: {
                3: true,
                4: true
            }
        }

当页面加载并且表格最初被填充时,这些功能可以正常工作.将为我的两列中的每一个创建一个下拉菜单,其中包含所有值.选择一个值会正确过滤该值.

When the page loads, and the table is initially populated, these functions work correctly. A drop-down is created for each of my two columns, and it contains all values. Selecting a value properly filters on that value.

但是,当页面运行时将新行动态添加到表中时,出现了我的问题.当添加包含新值的新行时,下拉菜单中的值不会刷新.触发更新",更改"等似乎无效.

However, my problem comes when new rows are dynamically added to the table as the page runs. The values in the drop-down menu do not refresh, when new rows are added that contain new values. Triggering 'update', 'change', etc does not seem to work.

在运行时向表中添加新行时,是否有办法动态更新此标准过滤器功能?

Is there a way to dynamically update this standard filter function when new rows are added to the table during runtime?

推荐答案

嗯,这似乎是过滤器小部件的问题.我已修复它,并更新了tablesorter存储库(现在为v2.7.2)

Hmm, this appears to be a problem with the filter widget. I've fixed it and updated the tablesorter repository (now v2.7.2)

这是一个演示,显示它现在可以正常工作了:)

Here's a demo showing it working now :)

感谢您报告此问题!

注意:没有任何代码,我无法提交此答案,因此这是更新表的方式:

Note: I couldn't submit this answer without any code, so this is how you should update the table:

$('table')
    .find('tbody').append(newRow)
    .trigger('update');

这篇关于更新JQuery Tablesorter过滤器功能的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-19 12:31