I have a Table with two buttons, Active and Inactive. When I click Active, I want to show all rows where the value of a field is empty and when I click Inactive I want to show all all rows where the value of the field is not empty.
I added an Event handler to the Active button like so
Hi @yourbudweiser! When you use the clearFilter API, the Filter ID should match the ID of the filter you want to clear. It looks like the filter ID for your active filter is {{ self.id }}, which I think evaluates to buttonActiveEmployees. So the clear filter ID should reference buttonActiveEmployees instead of buttonInactiveEmployees
You can also use the "clear filters" API to just clear all filters if you don't want to have to specify an ID!
The filter works as expected when using the Switch component, I just would like to apply the same functionality to buttons. So instead of True/False it would be Button 1 / Button 2.
Personally, I really prefer to setup predefined filters through a transformer that's monitoring states or something. I always find it feels more clear and easier to work with while editing the app. Not saying what should work but isn't should be ignored, but you might find it less of a headache now and in the future to shift your approach.
As a new user all ideas are really appreciated. Trying to figure out use cases for functionality that seemingly should work can be time consuming and difficult to implement. It seems to me that adding and clearing filters using event handlers is pretty straightforward as @mckenna alluded to in her first response.
I was able to get this working by using the click handler to run a script using setFilter and clearFilterStack
I'm glad to hear you have a working solution. We have the filter api in our docs, but it seems like we could supplement that with some best practices examples here in the forum