Patrick D
Patrick D

Reputation: 6849

Updating a JQuery Tablesorter Filter Function

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?

Upvotes: 3

Views: 3943

Answers (1)

Mottie
Mottie

Reputation: 86413

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

Upvotes: 2

Related Questions