Adding a dropdown to each row in Data

What I’m trying to do:
I’d like to put a dropdown containing responses from a Google Sheet in each row of a repeating panel.

What I’ve tried and what’s not working:
I’m able to do this in a single dropdown with no issues. The line of code below works just fine for a single dropdown. However, I want to duplicate that same dropdown for each row. I’ve looked at the documentation here: (Anvil Docs | Data Grids), and here: (Anvil Docs | Basic Components), but was unable to find quite what I’m looking for.

Code Sample:

self.drop_down_2.items = [(r["Responses"],r) for r in app_tables.allowable_responses.search()]

Clone link:
share a copy of your app

You’d set your repeating panel’s items property to app_tables.allowable_responses.search(), and then in your row template use data binding to set the items property of the dropdown to self.item['Responses'].

What happens is that the repeating panel automatically iterates through the list you set into its items property, and sets the item property of each instance of the row panel to the individual results.

1 Like

Thanks for the advice @jshaffstall. But that seems to give me one row again. Apologies if I’m missing something.

My repeating items propery is set to a server function.
image

At this point we’d need to see a clone link to be able to see what’s going on.

You have a data binding to columns in your data grid. Get rid of that and you’ll start to see the items show up in the repeating panel.

So should the repeating panel items be pointed to:

self.repeating_panel_1.items = anvil.server.call(‘get_data_table’)

or:

self.repeating_panel_1.items = app_tables.allowable_responses.search()

I’m not clear on that.

You have to set repeating panel items to a list or search iterator, so technically either one will work. But you also setup your data grid for a specific table. You must give the repeating panel a search iterator for that table.

I don’t still have your clone in my projects, but I’m pretty sure your get_data_table call is the one you want.

1 Like

Look at your data grid, and see what fields you have defined in it. Make sure you’re giving the repeating panel a search iterator for the table that has those fields in it.

1 Like

Thanks @jshaffstall! it’s working now, I appreciate your help!

1 Like