Nesting Repeating Panel With Simple Object

Hi I am trying to create a repeating panel inside of a repeating panel. One of my data table columns is a simple object and I would like to have that list of items populate the nested repeating panel. Any suggestions would be appreciated.

image

Essentially I’d like that third column to become its own repeating panel, inside the other rows.

image

Here’s one way to do it :
https://anvil.works/build#clone:TS52BOYOAJIQYKAA=HIETQ5IATYPNTEKG4UETSYEH

The main form passes an array of dicts to the primary data grid. This in turn sets the items for the embedded repeating panel. The embedded panel’s form then allocates each piece of data to a label in each of the embedded repeating panel’s columns.

I’m not at the top of my game by this time of night, so my explanation might be a little off, but you can see from the example app it works.

There maybe other (possibly better) ways; others may jump in :slight_smile:

1 Like

Yes, you should just be able to drop one inside another like @david.wylie said, as the template for the outer gets populated, the code inside it can take the data from the third (or whatever) column and put it into the .items property of the inner repeating panel.

In his clone link the data is pre-transformed to be nested, but you could put the code in the template of the outer repeating panel like:

self.repeating_panel_embedded.items = [ { f"e_column_{i}"  : x } for i, x in enumerate(self.item['column_3'], start=1) ]

…and it would transform the data to the way the repeating panel expects it to be.

2 Likes

Thanks. I got it to work!

1 Like

Thank you! I appreciate your help.