Is it possible to have dynamic filtering, as shown below?
I’d like the end user to be able to choose the search property and search operator on the fly. How would I approach replicating the below in a Bubble app. Thanks in advance!
Is it possible to have dynamic filtering, as shown below?
I’d like the end user to be able to choose the search property and search operator on the fly. How would I approach replicating the below in a Bubble app. Thanks in advance!
Yes, you can either set up the filter for this in the Do a search for action in the repeating group or use the advanced filtering method (:advanced)
The latter is a bit intensive from a workload units standpoint so you might want to use it carefully
Thanks Zeroic. But how would I dynamically pass in the operator when performing my “Do a search for”. I want to mimic the screenshot I provided where an end user could choose the search field and operator on the front end (and have these dynamically passed into the search constraint).
You can add Company = { your input field here }
Ex: you have a drop-down (called Dropdown D) with a list of companies. You can have the setup as Company = Dropdown D's value
Now say, you want the list of Users of a Company A. You select Company A in the dropdown and automatically the filter happens since your Do a search for has the condition of Company = Dropdown D's value
Dropdown D's value
is Company A
So it’s accordingly going to filter out the Users
Similarly, when you change the Dropdown D's value
to Company B on the page, Bubble will automatically filter out Users for Company B
Hope this helps
Hi there, in your explanation, you’re assuming the end user wants to use the “=” operator. But on the front end, I would like to include a “Search Operator” dropdown, where the end user could select “=”, “<>”, “is in”, “isn’t in”, “is empty”, and “isn’t empty”.
In other words, on the front end, I want to include three drop-downs: 1. For the Property (ie. Company), 2. For the Operator (=, <>, is in, is empty, etc), and 3. For the Value. Does this make sense?
Hey @markjkopelman
I see what you are trying to do I think.
Yes, you can do this. I have done this exact thing but I built out a SQL query with the data and then would pass it along to a SQL database to return the results.
There is probably a way to do the same thing but query your own database by exposing the data api and setting up your own api connection using the API connector.
Some ideas to get you going in the right direction.
Use option sets for your operators so you can have the ‘code’ in an attribute on the option set. Then you can reference this when building out your code.
I recommend creating a field that you can view on the front end for testing purposes so you can see if your code is coming out the way you expect before trying to pass it along to the api connector.
Does that help guide you in the right direction? It would take a lot of time to set up an example for you, but I’m hoping this will just get you going.
By the way, this is pretty advanced. I’ve been using Bubble since 2016 so I was able to do it. So it might take the average person a bit of time to work through it. Just one step at a time and you can do it.
To do this for an app with a Bubble database (i.e., not a separate SQL database), you probably need to use a technique often termed something like “daisy chain filter workflow”. There are forum posts and other online explanations, including A Beginner’s Guide to Advanced (Daisy Chain) Filtering in bubble.io | by Chike Ezeiru | Medium. Essentially, since you indeed cannot dynamically define an operator’s expression you instead trigger a series of workflows that iteratively funnel the list based on the user’s selected filter criteria, using conditions referencing the user’s selections to govern whether each individual workflow performs any filtering or instead just passes the unfiltered list through to the next workflow.
This is very helpful @J805 !
To clarify, I’m trying to query the Users data type within Bubble. I currently do not have or use an external database.
You’re suggesting an API call against the Bubble database and its Users data type would work? Or does the API call only work against external databases?
I think you can make a query using the API Connector to connect to Bubble’s database that you already have. You just have to figure out how to write it out for it to work.
It looks like you can do this using Bubble’s database. Here is the documentation that shows you what syntax it is expecting. Look under ‘List of Things’
Just what I needed. Thanks again for your help - really appreciate it!
Happy that helped.
This topic was automatically closed after 70 days. New replies are no longer allowed.