Store content panel content

Hello there!

So I have created an app with several forms. Here the first form is the main form with the graphs displayed on it and the other forms are input fields for the graphs. When switching between forms I would like to store the current version of the content panel of the main form. So, when I go back to the main form, the form does not run as if it loads for the first time (since this takes 30 seconds) but instead shows the last version of that form before the user had switched to a different form. Does anyone know how this is possible within Anvil?
Thanks in advance!

You can store the data retrieved in Modules and use them later.
Anvil Docs | Creating Modules

You don’t show any code, but I’ll assume you’re instantiating a new instance of the form every time the user wants to go back to it, e.g.:

form = MyForm()
open_form(form)

Or maybe using the self.content_panel.add_component(form) technique. Either way, you’re creating a new instance.

Instead of creating a new instance every time, store the instance you’ve created, so you can use it again. That will use the original version of the form the user has been interacting with. In Python terms, the form’s form_show will trigger again, but the form’s __init__ will not.

If you created a client side module using the technique from the link @divyeshlakhotia posted, you’d save the form instance to it, and then use that form instance for all open_form calls in the future.

3 Likes

Thanks for the help!

2 Likes