Ask a question
Here's how to add nested repeating groups to a Bubble app. To give an example of this, I have a repeating group set up here, which is of data type contacts. And I want to list all of my data type emails that are related to this contact. Let me show you how I have it set up in the database. So I have my contacts as a field in the email, and then I have my emails here I've got listed for out. So how do I show in a repeating group of contacts inside each contact a repeating group of emails?
How to learn Bubble
Before I launch into that, if you're learning Bubble, you've found our channel, hopefully you're finding many useful videos. But we've got even more Bubble tutorial videos on our website. You can't find them on YouTube anymore. You can only find them over on our website and they're exclusive to our members at planetnocode.com.
Adding a nested repeating group
Let's add in a repeating group. So we get a repeating group and add it into the cell of my contact and it's going to be type of content email. I'm going to design it first so we'll just have a column layout, get rid of the default four. My emails have got a text field of subject. Just going to make this all nice and well-designed and responsive as I go through. That's what I'm looking for. Right, now they only take up as much space as they need, especially if I get rid of the mint height. Okay, I now need to add an appropriate data source and so I'm going to do a search for email and I'm linking it through the email field of type contact.
When you can't find Current Cell's thing
So I need a way to refer to the current cell and if I go in and say contact equals... I don't have current cells contact. I've got current cells index but not current cells contact. That's because if we look in my element tree, and I think this is where people get confused, I'm using a group here to add in a background, group it all together. This can also be useful if you're wanting to link the whole cell, you put everything in the cell into a group. But that means I can't refer to the current groups, sorry the current cells contact. But the group does have the current cells contact and so in my repeating group for emails I can say current groups contact. Let's preview you that. Okay and you can see that the email titles are coming through. Now you may experience a situation where you struggle to find a way to link the data one up in your tree and so sometimes I find myself just creating a group that sits as the immediate child of the highest repeating group that's there because as long as that is between this group and this group I can refer to it in the 'do a search for'. So that's quite a handy workaround for when you can't directly refer to the current cell, you can refer to a group that is in the current cell, that has got the current cell's data.
Remember Workload units
A couple of other things with obviously necessary repeating groups is since the introduction of workload units you'll want to be thinking about how you can limit the strain or the pressure that you put on the database on the Bubble server side when you do a search for. So just bear that in mind because if you have a 100 records for each contact and you display five contacts, that isn't just five records being looked up, that is five records plus five times 100, so you're actually looking at 505 records being recalled from the Bible database. Obviously that's an extreme example, but I'm simply wanting to illustrate how it can easily multiply up if indeed you go down the route of using nested repeating groups.