Button in Datagrid accessing Row data

What I’m trying to do:
Hello everyone, I’m pretty new to anvil so forgive me stupid questions.

I created a small app with a Data Grid, getting data via a Data Table which is filled by a Server Call.
Data is received properly, and displayed in the Data Grid.

However, in the data table there is one column containing a Hyperlink to another website.
I want to achieve that, when the button of, e.g. row 3 is clicked, that the appropriate Hyperlink of this row is called (opening a new browser).

I tried to access the row in the button_1_click(self, **event_args) on click handler,
but I don’t know how to properly access the row data which contains the needed hyperlink.

Btw. opening the additional browsertab is not an issue right now.

Hopefully, you can point me in the right direction.

Thanks

Hi and welcome to the forum!

I assume that you call the server function, get a list of dictionaries (or datatable rows) and assign it to the repeating panel, something like this:

list_of_items = anvil.server.call('get_items')
repeating_panel.items = list_of_items

I also assume that the dictionary contains one url item.

If my assumptions are correct, then you can replace the button with a link and bind the url property of the link to self.item['url']:

image

3 Likes

Thanks stefano,

I really missed the link item, thanks for pointing me in the right direction.
It worked straight after making the data bind to self.item[‘url’].

Thanks again