Header Detail List (Master Detail) From Collections

Does anyone have any advice about how to create a header-detail list from two collections that are connected by a reference field? It seems like this should be easy, but I can’t figure it out.

What I am after is a page element that lists header items followed by their detail items. So, for example, if I have two simple collections relating to ice cream, one containing categories of ice cream and one containing flavors, with a reference to categories, I want a report that lists each category with each flavor following it, like this:

Header Detail Example - Report

The underlying collections would look like this:

Header Detail Example

Header Detail Example - Category Collection

Header Detail Example - Flavor Collection

Ideally one could use a repeater to generate this, although I am fine writing code to do it if needed. I am aware that nested repeaters are not possible.

Any suggestions?

Thank you!

1: the Master-Detail concept can be achieved by creating 2 collections and add a ref-field in the Flavor collection to the Cat., just like a foreign key in relational terms.
2: since some 2 years, Velo added the array and object field types. With this, you do not have to separate data into 2 collections, you can do with 1. So you would only have Icecreams, with the Cat as a normal field and the Flavors as an array or an array of objects. wix-data also made this type of field query-able
3. the repeater-inside a repeater problem can be circumvented by using 1 repeater, dumping every Flavor/Cat permutation in it. A query on the db will get you, in both scenarios rows with embedded data objects, either thru the ref-field or the array collection.
If you want a level break (like in your first example, where the word Ice cream is only shown once, you can achieve this inside the repeater by collapsing that field from the second row onwards.

Does this make sense?

Thank you, I’ll give it a try. Much appreciated.