Search code examples
tablesorter

TableSorter consecutive search


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?


Solution

  • 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