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
DataTable: Multiple filters for same field (AND) #8559
Comments
The datatable third party plugin support regular expression, so yes it feasible. In order to do, when applying programmatically the filter on a column, the person would need to provide additional parameter where it activate the regular expression and deactivate the smart search. See the docs here: |
Does this relate to my issue #8500 where I found the search lacking the |
I enable regex for the filters when introducing checkboxes. It be really simple to update it so it not looking for exact string. Also the regex I enable does not affect the search box. FYI. |
Also @michael-milette what do you mean by?
With the current design it searches using this code:
for checkboxes the value be Are you looking for it to search with Ontario AND Quebec instead of OR? Maybe the checkbox filer could be updated in away that allows for AND or OR...should this be predetermined or up-to the user searching? |
Hi @thekodester , Ideally we would like to give the user the option of selecting AND or OR. The checkboxes already provide the OR which is great. I am definitely using this feature. Just looking for a way to provide the AND now. It can be AND or OR like the advanced filter option in excel offers. Looks like this: It would preferably be on a per-fieldset basis and not a global setting. For example, I have another datatable where I have provinces, which I would like to OR, and a population type which I would like to AND or OR so that the user can select multiple population types in a given region of provinces. It would be most appreciated if you have any thoughts on how to make this happen. Best regards, Michael |
Hi @thekodester , Just wanted to confirm that you saw my reply last week. Best regards, Michael |
It wouldn't be overly complicated, but unsure if I be able to work on it right now. I do this in my free time when I have it. |
I understand @thekodester and thank you again - all of your efforts are so very much appreciated. |
This is the basic regex idea:
|
Filters:
|
Script:
|
I'm not sure if this should be merged in the filters demo or not. Any feedback on the code or ideas are Was just able to publish a live demo see: kodz.ca/projects/wet-boew/demos/tables/checkbox-filter I haven't done much testing so there probably some edge cases. |
You are absolutely the best @thekodester , Thank you so much Kody! I can't wait to try it out when I get back in the office on Tuesday. I will be sure to let you know how it work out. Best regards, Michael |
Hi @thekodester , Sorry for the delay in getting back to you. Life has a way of getting in the way. I implemented your code and it seems to work great so far. I think it would be great to see this included in the working examples. As you mentioned (and I missed - too excited to try it!), the fields need to be located outside the form. I feel that this issue should be addressed or it could lead others, like me, to wonder why the AND options always return zero (0) entries. Turns out that the solution is pretty straight forward. Just add the following lines right after the $regex = "" line. So far, it looks like these option fields can then reside within the form. // Ignore the Advanced Options fields.
if ($elm.context.name == "advance_options") {
return;
} For any documentation that you might be preparing (or to help others): Here is my understanding - assuming I have two check boxes, A and B that are selected. Please correct me if I have misunderstood of the Advanced Options:
Thank you again! Your help is so greatly appreciated. Best regards, Michael |
This options looks for ONLY A and B (together), so if you use the example on my site and pick ONTARIO and QUEBEC (or ONTARIO AND CANADA) should get a result of one or more. Not sure if your using the latest version I did make some changed to the script I posted about 9 days ago (noticed some bugs). |
Hi @thekodester , Thank you for the explanation about Whole Word (AND) option. Makes sense. I compared the JavaScript code you posted 9 days ago to the code in your working example page at www.thekodester.ca/wet/tables/checkbox-filter and they appear to be identical. This is what I am using. Is there a newer version somewhere that I should be looking at? I am assuming that there hasn't been any change for this in the wet-boew.js file. Best regards, Michael |
Oh I reread it and think I get it now. You mean adding the advance filters into the actual form. Sorry my confusion. |
Indeed. So for example, one of my pages has several drop down "select" fields and then one fieldset of check boxes. Now the AND/OR radio buttons will only apply to the checkboxes so I wanted to put the And/Or with the checkboxes to avoid any confusion (like people thinking that it would AND/OR the dropdown fields). In order to include the And/Or fields within the form, I had to add the previously mentioned lines of code. |
Contains Words is fine. I had to think about what Whole Word meant. In our forms, I actually preceded the list of checkboxes with something like "Include O Any or O All of the following checked terms:" for the "Contains Words" field. I felt this would be clearer to non-technical visitors. Still doing some Guerilla style QA testing around the office. As for Whole Word, I am still struggling to figure out how to explain this on the page in a way that won't require additional instructions. As you saw in my previous message, it wasn't even clear to me :-D Michael |
Maybe 'Keyword' or 'Exact Phrase' or 'Entire Word'? If explanation is need maybe something like: "It will only be applied if it matches the whole word/words." Also going off your original post could be: Any, Both, Either, And (with an explanation when hovered on)? |
Ha! It is so funny you suggested that. As a matter of fact, O Any, O Both or O Either is exactly what I came up with earlier this afternoon. Then I tried to translate "Either" into French and none of the francophones around me could come up with a translation. Even Termium and Larousse didn't have anything useful. I may need to give professional translators a shot at this. "Soit" came closest but it doesn't make sense on its own. |
Okay, we'll do up a PR. |
Hi @thekodester , I discovered an issue with the AND/OR script. It seems to break filtering of fields that contain numbers. For example, in our datatable, we have a field that contains just a single year (publication year). Without your script, it filters fine. As soon as I add your script, it returns 0 entries. Unfortunately our implementation is only on a development server so, to demonstrate the issue, I made a copy of the working example script from your site as well as your JSON file and put these on our public site with a base href so that it gets the WET files from your server. I added a "PUBYEAR" field to the JSON file and modified some of the dates so that it would return data for years 2016 to 2018. Then I added a select dropdown field to your form. See: https://cfc-swc.gc.ca/test/checkbox-filter.html Any idea why it would fail just with numeric fields containing years (it is our only numeric field)? Best regards, Michael |
Scratch that...gah...found the issue...needed some coffee. lol |
Sorry for the confusion. The example I had prepared for you had issues in the JSON file in addition to having the incorrect offset. It is fixed now. However, it still does not work using WET from your site. I have it working on our dev site (only without the extra JS for the AND/OR) however I pulled the latest version of WET from https://github.com/wet-boew/themes-dist.git I was happy to see the updated wet-boew.js included and that the AND/OR was working. I was surprised when the Year field failed. I was pretty sure I had checked this previously while using the wet-boew.js you posted when working on the checkboxes but I could be mistaken. Let me know when you figured it out. I will be happy to do some testing. Best regards, Michael |
Nothing to be sorry about, just my own confusion. The problem is the old patch (never triggered):
It too specific. Probably should be:
|
Hi @thekodester , Any luck with the numeric (Publication Date) filter field? You mentioned that you found the issue but didn't mention what it was. Not trying to pressure you or anything of course :-) Best regards, Michael |
Issue related too: #8592 (PR for the fix). |
I implemented the change you recommended. It doesn't appear to help. Are you sure that is the solution? I could be doing something wrong but it seems to me that the line right above the line you modified is a test to check for checkboxes: } else if ( $elm.is( ":checkbox" ) ) { How would that affect a "select" (dropdown) tag? Michael |
Should be all fixed now and I updated #8588. |
I updated the code so the advanced options only applies to one set of checkboxes. The PR has more info. |
Hi Cody,
Thanks for the update.
In case it is of interest to you or anyone else, here is the latest language we are using for the AND/ORs - which more people seem to understand.
In English:
o Includes any, o Includes all, o includes only or o includes just the combination of the following checked terms:
In French:
o Comprend, o comprend toutes, o comprend seulement les terms ou o comprend uniquement la combinaison des terms cochés suivants :
Best regards,
Michael
|
Hey it was approved and we'll be in the next release of WET. DEMO: DOCUMENTATION: Advanced Options Allows the user to change how checkboxes are filtered. Add data-aopts='{"type": "", "column": ""}' arrtibute to any checkbox/radio element to apply the advanced options. Available filter types:
As for naming the on the Front-end/User-end you can name them whatever works for you that is completely customizable since it only need |
This can be closed now. :) |
Does anyone know if there is a way to have multiple filters apply to the same field in a datatable?
For example, I have a province field which contains a commas delimited list of one or more provinces. I want to find all of the entries that include BOTH Ontario AND Quebec.
I tried the new Checkbox filter and, while it works great and we will be using it, it's filter returns results that include Ontario OR Quebec.
I also tried creating two province filters hoping that the second filter fields would filter the results produced by the first field. Unfortunately it only seems to take the second province filter into consideration, ignoring the first province filter.
Is there any way to have more than one filter apply to the same field?
Best regards,
Michael
The text was updated successfully, but these errors were encountered: