Mottie / tablesorter

Github fork of Christian Bach's tablesorter plugin + awesomeness ~

Home Page:https://mottie.github.io/tablesorter/docs/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Select filter filter-exact does not work with "-" characters properly

radium85 opened this issue · comments

Hello, I just find another use case, where exact match does not work correctly. I am referencing the issue #1486, where similar problem was solved. I modified the demo as example.

Problem occurs, when the value contains character -. I made a workaround and modified the code of tablesorter. I am not sure, if it does not beak something other, like searching with regex, but it works with my current use case.

Original code of tablesorter:

txt = fxn === true && (data.matchedOn === 'and' || data.matchedOn === 'or');
if ( filterMatched !== null && !txt) {
	result = filterMatched;

My workaround was to exclude also "range" matches:

txt = fxn === true && (data.matchedOn === 'and' || data.matchedOn === 'or' || data.matchedOn === 'range');
if ( filterMatched !== null && !txt) {
	result = filterMatched;

Hi @radium85!

You can exclude the range match for the whole table or a specific column using the filter_excludeFilter option.

Ok, this solved my problem. Thank you for the tip! - character is no longer taken into account when I exclude it using filter_excludeFilter option. And I do not have to modify the source code of tablesorter.

However, I would expect that filter-select with filter-exact option would compare filter value and cell value 1:1.

Hey @Mottie is there a way via class? Since all my code is generated and I've been fighting with this as well. I'd like to exclude range on anything with filter-select. My cols can change and since I"m using classes the php side won't know which cols have filter-select so I can't use it to generate a filter_excludeFilter list per col.

EDIT: Oh wait looks like I can add this globally?

    widgetOptions : {
      filter_excludeFilter : {
        // target a column by class name or column index (zero-based)
        '.filter-select' : 'range',
      }
    }

Good point, @TheSin- , I just modified my code, as you suggested and it works.