Updating the jQuery Tablesorter filter function

I am using jQuery Tablesorter, the latest version, using the Filter widget. In two columns, I use the filter function to display a drop-down list 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. For each of my two columns, a drop-down list is created and contains all the values. Choosing a value correctly filters that value.

However, my problem occurs when new rows are dynamically added to the table as the page starts up. The values ​​in the drop-down menu are not updated when adding new rows containing new values. Running "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 at runtime?

+2
source share
1 answer

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

Here the demo shows that it works now :)

Thanks for reporting this issue!

Note. I cannot send this answer without any code, so here is how you should update the table:

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

All Articles