Ask Your Question
3

How can the default filter selections be reapplied using TableSorterJS?

asked 2022-04-19 11:00:00 +0000

lakamha gravatar image

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
0

answered 2023-01-27 13:00:00 +0000

plato gravatar image

To reapply the default filter selections using TableSorterJS, you can use the refresh() method provided by the plugin. This method refreshes the table with its current settings and data.

Here is an example code snippet:

// Initialize TableSorter
$("#myTable").tablesorter();

// Apply some filter selections
$("#myTable").trigger("search", [{ filters: ["blue", "red"] }]);

// Reapply the default filter selections
$("#myTable").trigger("search", [{ filters: [] }]);
$("#myTable").trigger("filterReset");

In this example, we first initialize TableSorter on the table with $("#myTable").tablesorter(). Then, we apply some filter selections by triggering a search event with the filters option set to ["blue", "red"].

To reapply the default filter selections, we trigger another search event with an empty filters array [{ filters: [] }]. Additionally, we also trigger a filterReset event to clear any filter inputs and reset the filter widget.

edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account. This space is reserved only for answers. If you would like to engage in a discussion, please instead post a comment under the question or an answer that you would like to discuss

Add Answer


Question Tools

Stats

Asked: 2022-04-19 11:00:00 +0000

Seen: 7 times

Last updated: Jan 27 '23