Programmatically removing an object (ie. Button) from a repeating panel row

I have a data grid with a couple of columns where I’m dynamically creating row components depending on what’s in the data table for that row. So for example, depending on whether there’s a datetime object set in the data table, it creates either a button to launch a Check Out form and update the data table, or it shows the label with the previously checked out date. This is all working fine. Here’s my code from the main page:

if self.item[‘check_out’] is None:
button = Button(text=“CHECK OUT”, align=“center”)
button.set_event_handler(‘click’, self.check_out_click)
self.add_component(button, column=“HRXHOG”)
else:
label = Label(text=self.item[‘check_out’])
self.add_component(label, column=“HRXHOG”)

What I can’t figure out how to do is remove the button and replace it with the label in the self.check_out_click function later after the data table has been updated. By this I mean, how do I reference the unique instance of that button? I can see the <object if I run

self.get_components()

but I can’t figure out what it is I pass to

remove_from_parent()

ie. self.button.remove_from_parent() doesn’t work

I’m sure I’m missing something really simple here, but I need a smarter mind than mind to point it out :slight_smile:

Thanks,
Ken

Think I found the answer in this post:

Depending on how many potential cases you have to cater for, you could create the components and programmatically hide or show them. This obviously only works if the number of cases is known and not too large ie a button and a link would be easy to do this for as it is a simple if / else statement.

1 Like

Thanks Rick, that’s a good idea.
Ken