Question

I was wondering how to have a default filter value in tablesorter. I have a parameter being passed from one page to the next, and I want that parameter to be shown in the search box. I have tried to set the value after the page is ready by using

$(document).ready(function() {
        $("#listTable").tablesorter({ headers: {0:{ sorter: 'digit'}}, debug: false, sortList: [[0, 0]], widgets: ['zebra'] })
                    .tablesorterPager({ container: $("#pager"), positionFixed: false })
                    .tablesorterFilter({ filterContainer: $("#filter-box"),
                        filterClearContainer: $("#filter-clear-button"),
                        filterColumns: [1, 2, 3, 4],
                        filterCaseSensitive: false
                    });
        $('#filter-box').val("${showAccounts}");            
  });;

This does display the showAccounts parameter inside of the "filter-box" input, but it doesn't filter by it when the page loads. Is there any way to do this?

Thanks!

Était-ce utile?

La solution

You'll need to trigger filterEnd in your page load as well. Adding the below snippet should work.

$("#listTable").trigger("filterEnd");
Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top