How to update custom state of all groups affected by change?

Hi all,

I’m relatively new to Bubble and running into an issue. I’m making a hierarchical structure like so:

I have a custom state on the arrow (expandable?) that is yes and shows the arrow pointing right, then changes to no when the group is expanded and the arrow points down (to show it can be collapsed again). This is working fine for a direct parent-child relationship. However, in this example, if I collapse 1 while 2 is expanded, then expand 1 again, 2 still has a down arrow and the custom state expandable=no.

This is because I can only figure out how to change the custom state on the current groups element when collapsing. I can hide the data using make changes to a list, but I can’t change the expandable? state of all the items affected. Is there a way to do this?


Use nested RG in original RG. Just a heads up seems that the ux doesn’t seem to be super enjoyable with so many independent accordions

Hi @code-escapee, thanks for responding so quickly! Can you elaborate? I have this set up as 1 RG that displays/hides list items based on the expandable/collapsible arrow icon, indenting children as necessary.

When a collapse arrow is clicked on a parent, I can update all the data to hide its children, but it seems like I can’t set a custom state on all elements affected (e.g. if I could somehow loop across the list of child records and set the state, that would work, but I don’t see functionality to do that).

Check recent posts for nested RG. Not in front of a computer now

I did and wasn’t able to find something directly relatable. No worries, maybe someone else will come along tonight and be able to help too. :slight_smile:

I’m also thinking - I guess I could set up a new table for session data and store whether something is expanded or not as a database item, but that seems like overkill.

There are multiple recent posts about nested RG.


Haha, I hear you. Roger - will not take that approach.

I have looked at a number of recent and not-so-recent posts on RGs and I haven’t been able to troubleshoot this particular problem with them. If you get back to a computer and know of one/come across one you think will solve, I’d really appreciate a point in the right direction. Thanks again!

If ypu don’t solve by tom shoot me a message and ill find it for you

@code-escapee hope you had a great rest of your night, would love that point in the right direction if you have time!

Ok I finally understand the question. It seemed like RGs were being involved but they aren’t.

Solution is when closing 1 also change all subs expandable state to no.

Notes: expandable shouldnt be name of the custom state (its always expandable); also the custom state shouldn’t be on the arrow and in fact in your example all custom states should be on group section1_expanded, section2_expanded, etc so you can update all states with one action.

Hey @code-escapee,

There are three RGs. The first repeating group is the main list that displays all records (includes 1, 2a, 3a, 3b from screenshot). Rather than have sets of nested RGs to display children, all the list data is flat. Instead, there’s a RG ‘spacer’ that uses a blank column per parent to indent each RG based on how many parents it has in the hierarchy. Last, the arrow that expands/collapses is a RG with 1 column that populates if the record has any children.

When the arrow RG is clicked, I can change the custom state on that RG, but not all the custom states on children. So, for example, if I close 1 in the screenshot and open it back up, the arrow for 2a will still be pointing down, even though it will no longer be expanded.

Im not sure what you mean. There are 3 RGs but the first has all the data? Maybe making it flat isn’t the way to go. Regardless if you place the custom states for all accordions on the group level you can then change them all based on one user click

After researching on the forum and elsewhere, the flat structure seemed recommended for performance reasons if nesting gets complex over time. It works like this -

User clicks an arrow to expand. This passes data to a custom state ‘top of list’ which gets all the records up to the index clicked. ‘Bottom of list’ does the same for the bottom. Then it redisplays the list as the ‘top of list’ + records that have the parent of the expand arrow that was click + bottom of list. Collapsing reverses the process.

Re: your last suggestion, I can’t change them all in one user click because all might not need to be changed. For example, instead of the screenshot, imagine this hierarchy:


If, for example, I collapse 2a, I need to change the custom state on the arrow for 2a1, but not change the state on any of the rest, eg 2b or 2b1.

*Edited: ‘not change the state on any of the rest’

correct you’d have different WFs for each level of hierarchy - e.g., level 2 hierarchy changes custom states for 1 and 2

Sorry, that should have said, ‘but not change the state on any of the rest’.

There appears to be no way to change the custom state on a specific list of records or on a conditional like the record not being visible. In the WF as 2a collapses, there appears to be no way to affect other custom states programmatically.

Look at my previous responses :point_up:. Store the custom state on the parent group so, in one action, you can change however many you want.

I think I understand what you mean, I’ll give it a try - thanks!