Making rows in a DataGrid clickable

If you’re using anvil-extras you can achieve something similar to @duncan_richards12 suggestion with:

from anvil_extras import augment

class RowTemplate(RowTemplateTemplate):
    def __init__(self, **properties):
        ...
        augment.set_event_handler(self, 'click', self.row_click)

    def row_click(self, **event_args):
        print("row clicked")
    

Another approach comes from the data grid tutorials:

I think it’s the add widget tutorial.
You create DataRowPanel’s inside the RowTemplate - turning off auto_display_data
And to make the DataRowPanel clickable you can place it inside a Link component - looks like that question was already answered in the forum :wink: :

And then there’s the option of using:

both of which have row click events out of the box.

2 Likes