Anvil has been great so far, but I found an issue in displaying the data retrieved from databases.
Is there a way to have ‘persistent data’? Meaning, when a user goes to another form on the webpage, I want the data the user entered on the previous form to be saved.
I moved the post to Q&A since it’s a question about existing features.
In addition to the technique that @duncan_richards12 posted, you can also use a client-side module to hold global data that’s available to all client-side code. Do some forum searches on it and you’ll see a variety of techniques.
The Anvil extras persistence module is a good choice. So is passing the data to the next form as arguments especially is the data flow is linear and used only once.
If you are doing this regularly and on many forms I generally make a client side module and store dictionaries (or a list of dicts) there. That way you can just import the variable and do what you want with it.
I don’t understand the details of your implementation, but the way I “save” the data from the previous form is simply saving the previous form, which is an instance of a class and its content is stored in its attributes.
A form is a Python variable, and you can save a form just like you save any other Python variable, but I do it with the routing module from Anvil Extras. One of the goodies coming with the routing module is the (optional) caching of forms.
I can prevent the user from leaving a form without first clicking the Save button, I can always reload the data from the server when the form shows, or I can rely on the cashed instance.