Can I use a repeating group within a repeating group for an overview?

I would like an overview page that is associated with various tables grouped by date for a specific user eg
Joe Bloggs

26 August 2022
School Report details from report table repeating for all items on that date
Travel Report details from travel table repeating for all items on that date
Lessons Taken details from lessons table repeating for all items on that date

27 August 2022
School Report details from report table repeating for all items on that date
Travel Report details from travel table repeating for all items on that date
Lessons Taken data details from lessons table repeating for all items on that date

The repeating group rows would autosize to the data and provide a scrollable overview in a fixed format.

Is this possible? I cant see anything similar on the forums or I am missing it…

Thanks in advance for any guidance

There are various ways to do this…

The (kind of) obvious way is to have a RG with a content type of ‘date’ that has a datasource of 3 merged searches, those searches each being a Search for one of the 3 Type of things (School Report, Travel Report, and Lesson Taken), then using each items date, rounded down to Day, ‘Unique Elements’… e.g.

(do a search for School Reports: each item's date: rounded down to Day, merged with, do a search for Travel Reports: each item's date: rounded down to Day, merged with, do a search for Lessons Taken: each item's date: rounded down to Day): unique elements: sorted [descending: no]

That will give you a list of all the dates where one of the things you’re looking for will occur on…

Then, inside the RG cell, create a group for each of the 3 datatypes (each with a content type of date, and datasource of current cell’s date), and inside each of those groups add another RG, each with a content type of one of the 3 things you want to show…

Now, the temptation here is to set each nested RG datasource to be a database search… i.e. for the School Reports RG: do a search for School Reports [Date ≥ parent group's date | Date < parent group's date +(days) 1

But that will be terrible for performance, as you’ll be performing multiple searches inside every cell of the original RG… so don’t do that!!..

A better way will be to load all the relevant data of each datatype onto the page somewhere else (i.e. into 3 hidden RGs), with and then filter the data from each inside the 3 nested RGs in the main RG… that way you’re only searching the database once for each type of thing rather than multiple (potentially dozens or even hundred) of times inside every cell…

…in fact, you could use the 3 hidden RGs as the datasource for the original RG (instead of using database searches as outlined above)… it shouldn’t make any difference to performance (as the searches are identical, so should only be done once), but it will make things easier to manage on the page, so it’s probably the best thing to do…

Having said all that… possibly a simpler, and more performant, way to do this would be to create a new datatype especially for use in this RG, that has a date, and a list of each of the 3 type of things for the given date…

Make sure to update it (probably using database triggers) any time a new thing is created for the particular date…

Then you can just have a single RG on the page, of that datatype, then 3 nested RGs inside it, each with the relevant content type and a datasource of the parent group’s things list of relevant things…

Either way, you’re potentially dealing with a lot of data here… so how you go about it in terms of when/where/how you’re loading the data will make a big difference to the performance…

1 Like

Adam
Thank you for taking the time to reply, lots to think about and some great pointers there to give me ideas.
Many thanks

1 Like

Here’s a simple example of the first method: RG Grouped by Date (bubbleapps.io)

(having just checked in dev tools, it looks as though, contrary to what I previously assumed, actually Bubble is clever enough not to perform the searches multiple times, even when using ‘do a search for’ inside the RG cells… it sems as the searches for the various things are already being performed outside of the RG, each search is only made once, and any subsequent ‘do a search for’ inside the RG actually just use the original search filtered with the various constraints… so you probably can use ‘do a search for’ in the RG cell in this instance without issue… still personally I’d play it safe and not run searches inside the RG cells, but rather load the data elsewhere on the page then filter it inside the RG, as shown in this example)…

Thanks again Adam