1

It appears that tablesorter needs filter terms to match consecutively.

For example: A column contains: "Safe Rigging Practices for Seafarers"

Filter:

"Safe" returns the column

"Safe Rigging" returns the column

"Safe Practices" does not return the column.

Is there an option to change this behavior?

6
  • Can you add wildcards ? Maybe %Rigging% would return the column
    – vesuvious
    Aug 5, 2014 at 16:34
  • Thanks. Not sure if that will work or not, but we can't ask our customers to use special search characters.
    – Rick
    Aug 5, 2014 at 16:40
  • Could you just append % as both a prefix and suffix of all of their searches? They wouldnt have to put it in themselves.
    – vesuvious
    Aug 5, 2014 at 16:43
  • Is there an option for adding wildcards to the search in tablesorter?
    – Rick
    Aug 5, 2014 at 16:47
  • Ive never used the jQuery tablesorter itself, but have used other sorting and filter algorithms and they 'Usually' support wildcards of some type. I apologize if tablesorter does not support wildcards and this has led you in the wrong direction. I would have to read the documentation to know for sure.
    – vesuvious
    Aug 5, 2014 at 16:50

1 Answer 1

0

When you use a basic filter search, it only looks for a match of the query (from left-to-right), as you have stated above.

The filter widget also includes several different search types. See a full list in the docs at the top of this demo page. Here are several ways to get the results you desire:

  • As @vesuvious guessed, the search also supports wildcards, but in this case it uses an asterisk (*) to replace entire words (not including spaces). So try searching for:

    Safe * Practices
    
  • You could also use a logical AND by separating words using two ampersands (&&), or the word "and" (case insensitive). Both must be surrounded by spaces:

    Safe && Practices
    Safe and Practices
    
  • Lastly, you can use a fuzzy search to get the result by starting the search with a tilde (~):

    ~Safe Practices

7
  • How do you add a built in filter to an external filter input '$("#videoCourses").tablesorter({ initWidgets: true, theme: 'bootstrap', widgets: ["zebra", "columns", "filter"], headers: { 0: { sorter: false } }, sortList: [[0, 0]], widgetOptions: { filter_external: '.search', filter_columnFilters: false }, headerTemplate: '{content} {icon}' });'
    – Rick
    Aug 7, 2014 at 22:11
  • Use the filter_external option, which it looks like you have in the code. Check out the documentation, because that external input MUST have a data-column attribute set.
    – Mottie
    Aug 7, 2014 at 22:32
  • Right. Got the data-column attribute in the input: <input class="search form-control" type="search" data-column="all" placeholder="Search" /> Just don't know how to hook in the appropriate filter so the search will search on all words, not just consecutive ones. I must be missing something basic.
    – Rick
    Aug 8, 2014 at 2:48
  • That should be all you need to do.. setting the data-column="all" will make that external search search on all words. All the associated filter types will work as well. If you're still having problems, please set up a demo and I'll try to help troubleshoot the problem.
    – Mottie
    Aug 8, 2014 at 3:33
  • Thanks very much: jsfiddle.net/ricknew/zwmv6baf/10 Just want to be able to type in "Fire Prevent" and get the first item.
    – Rick
    Aug 8, 2014 at 4:11

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.