Displaying a hierarchy of things from a single data type

I am trying to display a three level hierarchy of company organisation units like this:

Corporate
-Business Unit 1
–Team A
–Team B
-Business Unit 2
–Team C
–Team D

I have a simple data type called OrgUnit with the fields:
OrgUnit Name - text
OrgUnitParent - reference to the record in OrgUnit that is the parent

The top level OrgUnit record has a blank OrgUnitParent field.

I am trying to display the hierarchy tree by using nested repeating groups.

RG-1 has a type of OrgUnit and a data source of a search on OrgUnit with a constraint that the OrgUnitParent field is empty. This works and only brings back “Corporate”

I then embed another repeating group inside RG-1, called RG-2.

RG-2 has a type of OrgUnit and a data source of a search on OrgUnit. So I think this initially populates RG-2 with all records in OrgUnit.

I then want to add a constraint to RG-2 to only show records where OrgUnitParent equals the ID of the current cell in RG-1. So it would only bring back Business Unit 1 and Business Unit 2 in my example.

This is the part I can’t get to work. Have I got completely the wrong approach?

I can see a similar discussion from a few years ago here: Building a dynamic tree list but I can’t view the editor attachment to see how it was being done.

Thanks for any help…

Hi there, @kevin39… I won’t comment on whether or not you have the “wrong” approach because it really isn’t possible to know that without knowing exactly what your app does and how what you have described fits into the app.

The above being said, what you described should work, and I set up a quick example that produced the following result.

Here is the setup of the second repeating group, and the constraint is looking to see if the orgunit’s parent orgunit is the current cell’s orgunit.

I am not sure why you can’t get it to work, but if you share some screenshots, I am sure we can figure it out because as you can see, it is definitely doable.

Best…
Mike

1 Like

Thank you, that worked with a tiny change to my parameters.

I am new to Bubble but have some experience with other approaches and I’m actually finding that a handicap :roll_eyes:

I was trying to select logic that was effectively “RG1-OrgUnit-Parent = RG2-OrgUnit-Parent”

“OrgUnit Parent = Current cells OrgUnit” wasn’t what I expected as it seems to compare a field with a record.

Oh and what constitutes “Current cell” is a struggle for me, is it in RG1 or RG2 :thinking:

Thanks again :+1:

1 Like

One further question as I can see you have already cracked it :slightly_smiling_face:

How did you set out the layout of the nested repeating groups such that they’re laid out neatly?
It looks as though the rows in RG2 grow in height to accommodate the number of associated rows in RG3

Thank you for your help!

I didn’t put too much thought into it for the example, but here’s what my setup looks like.

I also used a fixed layout for the example because I wasn’t trying to care about responsiveness. You probably will care, I’m guessing.

1 Like

Phew, fast response!

To show I’m trying, I read up on the layouts, when I set the page, RG1, RG2 and RG3 to ROW I got a got a much bettter layout.

I will also try your fixed version to compare.

Cheers

To be clear, I only used the fixed layout because I never care about responsiveness in examples I create for the forum (unless the example is for a question that is related to responsiveness, of course). I almost never used a fixed layout in any real app.

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