Search code examples
phptablesorterjscript

How to filter from external input and startswith?


I'm trying to filter a table content with tablesorter applying two filters at the same time, but the table is not being filtered with filter_startswith when the "filtertext" is being taken from an external input.

The startswith filter works fine when the "filtertext" is from columnFilters, but with the external input the filter works but ignores the startswith filter.

From the source example I added the external input to filter, the rest is almost the same.

Is this an expected behavior or can it be called a bug/error/problem with the widget? How can I make what I want? (filter the table from an external input but with the startswith filter)

Source example: http://mottie.github.io/tablesorter/docs/example-widget-filter.html


Solution

  • I set up this example with the filter_startsWith option set to true and it appears to work when I try to filter the first name column for "a"; the only results I see are "Aaron" and "Alex", not "Philip Aaron" or "Martha".

    $(function() {
    
        $('table').tablesorter({
            theme: 'blue',
            widgets: ['filter'],
            widgetOptions : {
                filter_external : '.search',
                filter_startsWith: true,
                filter_reset: '.reset'
            }
        });
    
    });
    

    If this isn't working for you, then please modify the demo to show the problem so I can help troubleshoot it.