Skip to content

Filter widget: filter-select should default to exact matches #102

Closed
riker09 opened this Issue Jul 9, 2012 · 7 comments

2 participants

@riker09
riker09 commented Jul 9, 2012

When using the filter-select widget it should have an option to switch between exact matches and lazy matching, defaulting to exact matches. An example:

  • ABCD 1
  • ABCD 2
  • ABCD 2
  • ABCD 3
  • ABCD 1
  • ABCD 12
  • ABCD 12
  • ABCD 24

The drop down should show ABCD 1, ABCD 2, ABCD 3, ABCD 12, ABCD 24. When selecting ABCD 1 only rows containing EXACTLY this value should be visible. I think the best usage would be as another headercolumn option:

<th class="filter-select match-exact">name of column</th>

I know, this usage is the opposite of the earlier proposed default.

@Mottie
Owner
Mottie commented Jul 9, 2012

Hi riker09!

Hmm, I'm guessing ABCD 4 should have been ABCD 2.

Right now, and this is completely unintentional LOL, you can set the filter-select class on a column, and it will only "match" the results; but if you set widgetOptions.filter_functions[column] = true; it will look for "exact matches" only.

It shouldn't be a problem to add a class to modify this behaviour. But how about if we use filter-exact or filter-select-exact?

@riker09
riker09 commented Jul 10, 2012

Yes, you are right. That should have been ABCD 2. I have fixed that in the original post.

I can confirm that setting widgetOptions.filter_functions[column] = true; is a useful workaround. I'm setting this value like this:

jQuery.tablesorter.defaults.widgetOptions.filter_functions = { 1: true };

Where 1 is the column where I need exact matching.

I'm not sure wether I like the filter-exact or the filter-select-exact approach better. With the first option the exact matching can be transferred to other columns more easily. One can have exact matching on normal filters as well.

@Mottie
Owner
Mottie commented Jul 10, 2012

Ok, I like your suggestion about making the column only exact match when the class name of filter-exact is in the table header.

But now I'm wondering if selects should have an exact match by default and all other columns only match by default. Then we'd need a filter-match class for the selects.... ugh.

@riker09
riker09 commented Jul 11, 2012

I can follow you all the way to "But now I'm wondering if selects should have an exact match by default...". This makes sense. If I specifically pick a value from a filter-select column the default behaviour should only display rows with exactly this value.
I don't think this feature should be added to other colums, though. Is stated above there's a perfectly working code snippet around that does just that. If it is easier to implement exact matching as a default for filter-select then you should go for it and give the filter-exact class name feature a very low priority.

@Mottie
Owner
Mottie commented Jul 11, 2012

Ok! That was actually my question earlier, maybe it didn't come out correctly. But I was asking if the filter-select should have an exact match by default, then if you wanted it only to match, add a class name of filter-match to make it not-exact.

@riker09
riker09 commented Jul 12, 2012

Judging from the requirements I'm facing in a current project I'd say that it's enough to have the filter-select function doing an exact match all the time. I don't have the need for filter-match, but that's just me.

@Mottie
Owner
Mottie commented Sep 27, 2012

Ok, you can now add filter-match to the header cell to make the select match instead of exact match in version 2.4, now live :)

@Mottie Mottie closed this Sep 27, 2012
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.