How to add a button to clear custom state and display all items in a list in a recurring group

Hi,

I’m new to Bubble and going through tutorials to get a hang of it.

Below is a sample listing app I created.

  • It has two data types: User and Team.
  • Every entry in the User type will have a Team field.
  • I created a recurring group to list all the users and have another recurring group to display the teams.
  • I’m filtering the user list based on a custom state for the team. This setup is working as it should.
  • Now I want to add another button ‘All’ which, when clicked, would display the list of all users. I want the ‘All’ button to use the custom state setup and not have to reload the page which resets the state and by default lists all users.

I’d appreciate any help. Thanks in advance.

Set a (blank or all) value for the custom state on repeating group add a conditional statement for when this value is (blank or all) and define the data source when the value is (blank or all).

I think you want to be able to filter which users are displayed in your repeating group based on the filter which is a customs state holding a value of a team.

So if your custom state has a team value in it, the repeating group of users only shows the users who are part of the team that is currently held in that custom state.

Now, you want to add a button that will allow you to show all the users in the repeating group.

What that button should do is ‘reset’ the custom state filter of team. To do that, add a button, create a workflow for when that button is clicked. This workflow will have one step, which will be to set the customs state of team…do not add any value to the custom state, which would make it ‘empty’ or ‘blank’ and therefore removing the team that had previously been the value.

Since this custom state would have an empty value, your user repeating group would no longer have a constraint of team restricting the user list, and will show all users in your database.

Another thing you might do, if you are selecting the team to add to the custom state using a checkbox from the team repeating group, make it so if that checkbox is selected after that particular team is the custom state value, it will ‘reset’ that custom state.

So one click to select the team, a second click to deselect the team.

You can set up in workflows two events using conditionals on the one checkbox (I personally use icons for this)…the first workflow is to set the custom state to the team value…the conditional on that workflow is ‘when custom state team doesn’t contain current cells team’.

A second workflow action when the icon is clicked will have a conditional ‘when custom state team contains current cells team’ and the event will set the custom state of team to an empty value.

If you use an icon to do this, you can also change the icon in the icon conditional. I usually have an icon that is a checked box, then in conditional change the icon to an empty box.

Screen Shot 2020-11-26 at 12.54.19 AM Screen Shot 2020-11-26 at 12.54.25 AM Screen Shot 2020-11-26 at 12.54.44 AM

The conditional you would use to change the icon is ‘customs state team doesn’t contain current cells team’

1 Like

Hi @boston85719,

Thanks for the detailed answer. It worked for me.

1 Like

This topic was automatically closed after 70 days. New replies are no longer allowed.