Hi guys!
I’m kinda stuck in my own design and I need your help!
Here’s what I have:
The homepage have links that lead to another page with a period value, self.item passing to the other page. On the other page, I used a repeating panel to list bills with amount depending on the period value. These bills also have a delete link. When I use the delete link, it works great. The only problem I have, is the label with the total of the bills. I cant find a way to update the label when the delete link is hit, since the repeating panel is a child to the parent. Perhaps my whole approach is wrong.
The question :
Is it possible for me to trigger a function or some kind of update from the child to the parent?
PS : I would love the know how you are doing this king of stuff in your projects! I mean how to deal with aggregate (total) and list of rows (repeating panel).
Events work well, as described in Tony’s link. I specifically put the event handler on the repeating panel so that the row items can call self.parent.raise_event.
try checking what self.parent is using print
did you just before call self.remove_from_parent()
if yes… then it no longer has a parent.
you can store the parent before you remove it…
def link_1_click(self, **event_args):
parent = self.parent # still on the screen
self.remove_from_parent()
parent.raise_event('x-update-labels', arg=arg)
worth being cautious with this approach - if you change the components but don’t adjust repeating_panel.items you may wind up with a reappearing item. Since your UI no longer matches…
What is a good way to cleanup the repeating_panel.items that the user removes. Say you have a ToDo list and you want to remove the item somewhere in the middle of the list. As you said, just doing self.remove_from_parent() will only remove the item from view but not update your list if another function retriggers the repeating_panel to reshow the items.
My use case does not have a database, the data is simply cached in a python list, so updating a database as this tutorial (Storing and Displaying Data with Anvil - YouTube) shows would not work for me.
The original question, under the original title, has been answered. Recommend that you start a new question, with a suitable title, so that people can see it and know that it has not been answered yet.