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

FilterUtils.filter only accepts filterValue of type string #8348

Closed
hainesrdacorp opened this issue Nov 21, 2019 · 1 comment
Closed

FilterUtils.filter only accepts filterValue of type string #8348

hainesrdacorp opened this issue Nov 21, 2019 · 1 comment
Assignees
Labels
Type: Enhancement Issue contains an enhancement related to a specific component. Additional functionality has been add
Milestone

Comments

@hainesrdacorp
Copy link

I'm submitting a ... (check one with "x")

[x ] bug report => Search github for a similar issue or PR before submitting
[ ] feature request => Please check if request is not on the roadmap already https://github.com/primefaces/primeng/wiki/Roadmap
[ ] support request => Please do not submit support request here, instead see http://forum.primefaces.org/viewforum.php?f=35

Plunkr Case (Bug Reports)
https://stackblitz.com/edit/github-svm8kf

Current behavior
Cannot call FilterUtils.filter(...) and pass a filterValue of anything other than a string type.
Cannot use filterMatchMode 'in' because an array of values cannot be provided.

Expected behavior
FilterUtils.filter(...) will accept a filterValue of any type. FilterUtils.filter(...) will pass filterValue to appropriate filterMatchMode (in) to filter the set.

Minimal reproduction of the problem with instructions
const filtered = FilterUtils.filter(this.cars, ['make'], ['Audi', 'BMW'], 'in');

What is the motivation / use case for changing the behavior?
Using existing filtering for custom component to determine result of filters.
Use the same set of filters currently applied to a p-table => apply those filters to a custom component

Please tell us about your environment:
Windows, VS Code, npm, express

  • Angular version: 8.0

  • PrimeNG version: 8.1.1

  • Browser: [all ]

  • Language: [all | TypeScript X.X | ES6/7 | ES5]

@hainesrdacorp
Copy link
Author

hainesrdacorp commented Nov 21, 2019

My current work-around is to create a custom filter and add it to the filter utils dictionary and call that instead. This is undesirable though because now I have to look at each filter individually and see if it is a 'contains' or an 'in' and do different logic depending. I have also created a custom filter already to handle between two numbers and I now have to create another custom filter to handle filter input in string format instead.

export const SpliceIn = (value, filter: string): boolean => { const arrayFilter = filter.split(','); return FilterUtils.in(value, arrayFilter); }
...
FilterUtils['spliceIn'] = SpliceIn;
const filtered = FilterUtils.filter(this.cars, ['make'], ['Audi', 'BMW'].toString(), 'spliceIn');

@cagataycivici cagataycivici added the Status: Pending Review Issue or pull request is being reviewed by Core Team label Mar 31, 2020
@cagataycivici cagataycivici added this to the 9.0.4 milestone Mar 31, 2020
@cagataycivici cagataycivici self-assigned this Mar 31, 2020
@cagataycivici cagataycivici modified the milestones: 9.0.4, 9.0.5, 9.0.6, 9.FUTURE Apr 1, 2020
@cagataycivici cagataycivici removed this from the 11.FUTURE milestone Nov 17, 2020
@cagataycivici cagataycivici added Type: Enhancement Issue contains an enhancement related to a specific component. Additional functionality has been add and removed Status: Pending Review Issue or pull request is being reviewed by Core Team labels Nov 20, 2020
@cagataycivici cagataycivici added this to the 11.0.0-rc.2 milestone Nov 20, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Type: Enhancement Issue contains an enhancement related to a specific component. Additional functionality has been add
Projects
None yet
Development

No branches or pull requests

2 participants