Updating a JQuery Tablesorter Filter Function

…衆ロ難τιáo~ 提交于 2019-12-06 07:21:44

问题


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?


回答1:


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 :)

Thanks for reporting this issue!

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');


来源:https://stackoverflow.com/questions/14223044/updating-a-jquery-tablesorter-filter-function

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!