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.
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.
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.
One further question as I can see you have already cracked it
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
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.