Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Wildcard filter behavior #727

Closed
glend1 opened this issue Sep 22, 2014 · 11 comments
Closed

Wildcard filter behavior #727

glend1 opened this issue Sep 22, 2014 · 11 comments

Comments

@glend1
Copy link

glend1 commented Sep 22, 2014

Hi,

I have a Tablesorter Jquery object on a webpage, I have managed to get it working as I intend. There is, however, a small issue. Wildcard filters do not seem to work logically. After removing the other filter types (using the method described here; http://mottie.github.io/tablesorter/docs/example-widget-filter-custom-search.html) to ensure none were conflicting. I then filter using the phrase "test" and all other "test1", "test2" and "test3" results match, this is not logical behavior because when I filter "test|something" I loose test1/test2/test3 results.

I tested with and without exact filter types but the exact type doesn't trigger unless you include a = or ".

Using UI conventions I agree with with the way it is automatically detected and currently done. Perhaps you could allow "text" filter type to be turned off/deleted and include a partial match type with a higher priority than wild.

As a temporary work around I force regex. /^text$|^text$|^text$/i

@Mottie
Copy link
Owner

Mottie commented Sep 22, 2014

Hi @doveyg!

The wildcard filter is set up to exactly match content when you use a logical "OR", so using test|test 1 will only find test and test1, and nothing else (like test10).

If you want the wildcard to match content, then add a "filter-match" class name to the header (demo).

Hopefully that makes everything work as you would expect.

@glend1
Copy link
Author

glend1 commented Sep 23, 2014

I don't see any behavioral changes. when you type "test" without the quotes nothing is removed, as apposed to showing just 1 match, "test".

@Mottie
Copy link
Owner

Mottie commented Sep 23, 2014

Maybe adding a second table to the demo will clarify things?

@glend1
Copy link
Author

glend1 commented Sep 23, 2014

I see. The issue I see is that on either table if you enter exactly "test", without the quotation marks. then it goes into Match mode. It would seem that the class is ignored until you put "|" in.

@Mottie
Copy link
Owner

Mottie commented Sep 23, 2014

Huh? When I type in "test", it matches all content with "test" in both tables. It's when you type in "test|" that it appears to exactly match "test" in both tables, until you start typing something else, e.g. "test|a".

@glend1
Copy link
Author

glend1 commented Sep 23, 2014

It's not strange to you that when you go from "test" to "test|" to "test|abcd" you get 9-1-2 records using exact? or "t" to "t|" to "t|a" you get 9-0-10 records using match?

In my option, "t|" should count as "t" on filter match. While "test" should count as "test|" using filter exact.

@Mottie
Copy link
Owner

Mottie commented Sep 23, 2014

Hmm, you're right, that should be changed. I'll see what I can do after I finish working on these other updates ;)

@Mottie Mottie added the Bug label Sep 23, 2014
@glend1
Copy link
Author

glend1 commented Sep 24, 2014

Side note. Which are the most efficient/fastest filter types? I imagine; wild is one of the slowest, exact the fastest and regex somewhere in between.

@Mottie
Copy link
Owner

Mottie commented Sep 29, 2014

Please try the update available in the working branch. Here is an updated demo using that change.

@glend1
Copy link
Author

glend1 commented Sep 30, 2014

still behaviors strangely imo. typing "test" into exact returns 9 results. typing "test|" into exact returns 10 results. i would expect a single result for both.

@Mottie
Copy link
Owner

Mottie commented Sep 30, 2014

The "exact" part only applies when you are using the "or" operator.

If you want to always get exact results, either define a filter function:

filter_functions: {
  // Exact match only
  0 : function(e, n, f, i) {
    return e === f;
  }
}

or set a default filter:

filter_defaultFilter : {
  0 : '{q}='
}

But as I said before, I keep an open mind about making changes. Anyone else, like @TheSin- or @thezoggy, want to chime in here?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants