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

Multi-Select filter bug - not working on values that contain a space. #611

Closed
shaneyEB opened this issue Jun 2, 2021 · 5 comments
Closed

Comments

@shaneyEB
Copy link

shaneyEB commented Jun 2, 2021

Currently, I am using operator: OperatorType.inContains, and the filter only works if the values do not contain any spaces in them. It will not return any results for values that contain a spaces. Please see the ShareX for more details.

akF3STqWcc.mp4
@ghiscoding
Copy link
Collaborator

ghiscoding commented Jun 2, 2021

Hello, I'm not really sure why you've opened this issue in SlickGrid core lib because this is an Angular-Slickgrid specific feature.
The IN_CONTAINS filter uses the code from this line which is

    case 'IN_CONTAINS':
      if (value2 && Array.isArray(value2) && typeof value1 === 'string') {
        return value2.some(item => value1.split(/[\s,]+/).includes(item));
      }
      return false;

So I don't know what your text values are but it probably doesn't pass this test condition.
What's the reason that you're using the inContains?
I mean the default is IN with exact values and the only time you should use this filter type is when you want to use a dropdown Filter and your values are something like a CSV string
You might want to try inCollection that I added few months ago in this PR

a good, and rare, example of when inContains could be useful is this Angular-Slickgrid Example 27 that have values as CSV (comma separated values)

image

@shaneyEB
Copy link
Author

shaneyEB commented Jun 2, 2021

Thanks so much for your help. The IN_COLLECTION is working for my multiselect. I had to re install to get your latest fix that was put in on March 18. I also want to apologize for putting this request in the wrong place. I will submit future request in the angular-slickgrid support. I do want to point one thing out on example 27 it did not work for me. If you select a value with a space it does not work. Please see picture below. Again thank you so very much for your help. Have a wonderful day!
example27

@shaneyEB
Copy link
Author

shaneyEB commented Jun 2, 2021

Thank you for your speedy response and your great support. Have a blessed day!

@shaneyEB shaneyEB closed this as completed Jun 2, 2021
@ghiscoding
Copy link
Collaborator

I also want to apologize for putting this request in the wrong place. I will submit future request in the angular-slickgrid support.

No problem, just wanted to highlight this because we are 2 different projects and maintainers of this lib 😃
Sometime the issue(s) are in Angular-Slickgrid but sometime they are in SlickGrid core lib, it all depends what the issue is, if you know which one is which then that helps us ;)

If you select a value with a space it does not work.

Ok good to know, I think the regex is too restrictive, I'll take a look at it later, thanks for the info

Glad to know you got it working
Cheers ⭐

@ghiscoding
Copy link
Collaborator

ghiscoding commented Jun 2, 2021

and before I forget, I took a quick look at it and fixed it, I simply needed to add a trim to the string values to inspect and now it works. So thanks for reporting this (even if it was in the wrong lib) 😉

Also note that as I wrote in the comment of the IN_CONTAINS, that filter type is mostly oriented by be used with a CSV string.

  case 'IN_CONTAINS':
      if (value2 && Array.isArray(value2) && typeof value1 === 'string') {
        return value2.some(item => value1.split(/[,]+/).map(val => (val.trim())).includes(item));
      }
      return false;

image

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

No branches or pull requests

2 participants