Communication between row templates

I have a main form in my app ‘frmMainSheet1’ with a 2 column data grid in the content panel . The row template for this data grid / repeating panel is called ‘RowTemplate4’. Column 1 of this template contains a simple label. Column 2 of this contains a second data grid who’s repeating panel has the template ‘RowTemplate5’. One column of this template contains a drop-down.
What I want to happen is that when a drop down changes the on_change event should update the underlying data table (easy) and then update the text of the label in the corresponding row of the outer grid

The function GetNumbers() in the ‘RowTemplate4’ code should update the label as I would like but how do I trigger this function from the on_change handler of a drop-down on ‘RowTemplate5’?

Code Sample:

# this is a formatted code snippet.
# paste your code between ``` 

Anvil | Login
share a copy of your app

You might want to have a look at the Messaging module of anvil extras.

Thanks Owen. The messaging module looks interesting but I don’t think its really what I need in this case.

I have tried using a custom event, ‘x-update-numbers’. The event handler and its assignment are in the code of RowTemplate4, the template for the outer data grid’s repeating panel. The event is raised at the end of the On Change handler for the drop down in the Row Template 5 code. When I run the app the drop down’s On Change handler runs (underlying data gets updated) but the handler for the custom event does not. Any one got any ideas?

Your original clone link isn’t valid any more. I don’t think you’ll get any useful help without someone being able to look at exactly what you’re doing. There are a lot of ways for what you’re trying to go wrong.

Sorry about that. Here’s the link.

It looks like you misspelled the event name when setting the event handler:

self.repeating_panel_Inner.set_event_handler('x-update-nubers', self.GetNumbers)

Instead of:

self.repeating_panel_Inner.set_event_handler('x-update-numbers', self.GetNumbers)

Anvil apparently doesn’t give an error when you raise an event that has no handlers, so the raised event just didn’t do anything.

2 Likes

Thanks Jay. I stared at this for hours and still didn’t see it. The event is now successfully raised and the handler runs.

3 Likes