-
-
Notifications
You must be signed in to change notification settings - Fork 29
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
feat(filters): add a filterPredicate
option for user customization
#1528
Conversation
- adding a `filterPredicate` would help user who want to have a custom filter predicate callback that cannot be handled by built-in filters - also added a patch filter version, that was only for testing purpose (will probably remove before merging) and to provide a way to answer the SO question: https://stackoverflow.com/questions/78471412/angular-slickgrid-filter
Run & review this pull request in StackBlitz Codeflow. |
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## master #1528 +/- ##
========================================
+ Coverage 99.8% 99.8% +0.1%
========================================
Files 198 198
Lines 21616 21621 +5
Branches 7219 7221 +2
========================================
+ Hits 21555 21560 +5
Misses 55 55
Partials 6 6 ☔ View full report in Codecov by Sentry. |
@zewa666 I wouldn't mind a PR review, it brings a Currently the slickgrid-universal/packages/common/src/interfaces/column.interface.ts Lines 339 to 340 in 4284d58
|
so the predicate would essentially by-pass the built-in filter service filtering function? what happens to the operators though? I'm actually very interested in the exact same case searching using an asterisk character but I thought of that more along the lines of being a new operator and also working for the OData backend with either eq operators including the wildcard or a custom odata function. |
yes
hmm yeah I forgot about the operator and after testing it locally, the operator is parsed prior to the filter predicate call and is included in the filter: {
filterPredicate: (dataContext, searchFilterArgs) => {
console.log(searchFilterArgs);
}
} is giving this console, it is currently set as if I type "*Ta" then the operator becomes "EndsWith" which is the typical operator detection. If the user wants to use something else as operator he could just parse the search value for whatever token he wants to use. I also added a |
oh ok thats great, didnt notice that one. guess thats also on the next branch right now? while at it can we also define what the visible text will be in the operator dropdown? e.g for the like I'd like to have "a*b" as that is neither starts nor ends with but also not contains. back to the original question though, ideally the dev wouldnt pick a filter type that allows to select an operator if he provides a custom filterPredicate in order to reduce UI complexity for the users. filterPredicate sounds good as well as predicate alone might not be intuitive enough as you said hmm also note your implementation is not exactly correct as while %Ta% might be a contains what about %Ta%1? So the wildcard is treated like a regex dot-character zero or multiple times. here is an example |
I merged it this morning so it won't be available until I publish a new release, v5.1 of universal
You can already provide alternate texts as per docs (because someone requested it). However there's no way at the moment to change the list of compound operators, that is currently analyzed by the column slickgrid-universal/packages/common/src/filters/inputFilter.ts Lines 220 to 241 in 4284d58
slickgrid-universal/packages/common/src/filters/filterUtilities.ts Lines 125 to 152 in 4284d58
Maybe what we should do is to modify the current slickgrid-universal/packages/common/src/filters/filterUtilities.ts Lines 160 to 171 in 4284d58
|
The user can provide a
bahh I don't care that much, I did improve it but forgot to push the commit (which I just did). I mean, I spent like 2 hours trying to get it working with regex and just gave up and using I guess more filter features could be added in separate PRs. |
as for this PR itself I think that's fine as is. everything else would be a different, although related topic, and hence worth another PR. |
hahah taking another look at my own docs, I forgot that I actually already done the change for a completely custom compound list.. dohhhh 😆 See Compound Operator List (custom list) which is just above the section "Compound Operator Alternate Texts".... isn't that great, when you just realized there's nothing more to do haha The only thing left I guess would be to provide custom operators, I still don't know how we could do that though. Because, currently I use I don't see a way to address this without a breaking change, which I'm not looking to do at all. Not just because I just released a breaking change version but mostly because of usability, it's easy as it is today to write either in theory, I could still do breaking changes if I want, because I would very surprised if anyone upgraded yet in Aurelia-Slickgrid/Slickgrid-React. BTW, are you still using Aurelia or..? It's taking forever to release Au2 but recently bigopon mentioned they're getting closer to RC (better late than never I guess) |
not actively using Aurelia any longer sadly due to timeconstraints and lack of projects. thx for all the info, I guess with the one new Operator.Custom I should be all set for my needs |
I don't mind adding couple of extra operators (like |
Hi @ghiscoding, I'm in the old version of P/S: I'm using Updated: After reading the StackOverflow post, it seems like the only way for old versions to achieve this functionality is by patching the |
@ngcvm The Stack Overflow answer does show you how to do it with an old version and yes it's achievable. I spent a lot of effort to not just add this new option but also to answer that SO, so you should give it a try... and sorry but I just don't have time to support old versions, I'm not being paid for any of this either (though I did get a large Ko-Fi donation from that user), so... good luck |
@ghiscoding Thank you for your answer and amazing works. |
filterPredicate
would help user who want to have a custom filter predicate callback that cannot be handled by built-in filtersTODOS