A simple clone is always useful; however, it sounds like you need to reach back to the template’s parent in order to get access to the items
.
You can call get_open_form().some_method_to_deal_with_your_items()
from inside your template form. Or use a call to parent
, but depending on the structure, that is not always a good idea.
Please see these posts for some context:
that’s a little fragile, despite it actually working.
You should maybe keep a reference to the form in Form1. For example :
self.my_new_form = Form2()
self.content_panel.add_component(self.my_new_form)
then you could do this from anywhere :
get_open_form().my_new_form.my_function()
Hi @david.wylie and @meredydd
Thanks for these helpful tips. I have a question about what is most “Anvil-ic” (best practice) about displaying a new page in an app. So far I have used three methods for this:
open_page('my_new_page')
self.content_panel.clear()
self.content_panel.add_component(my_new_page())
get_open_form().content_panel.clear()
get_open_form().content_panel.add_component(new_page)
I can see that method 3 works well if you are sitting on a component that lives inside…
If you want to add to a row in the repeating panel, you could modify its items.
Try inspecting self.repeating_panel_1.items. It is a list of dictionaries/rows.
If you want to add a data row panel, could you use add_component and rearrange the full component list?
Example,
label=Label(text='put me first')
row=DataRowPanel()
row.add_component(label, column=1)
comps=self.data_grid_1.get_components()
comps.insert(1, row)
self.data_grid_1.clear()
for c in comps:
self.data_grid_1.add_compon…
1 Like