cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Anonymous
Not applicable

How to repopulate what was selected inside of a gallery from a record in the database?

Hi 
I have Gallery which holds a Collection of Restaurants. 

What i am trying to achieve
how can i save what was selected in the checkbox and repopulate what was selected in the checkbox when i open the app again?


 Resturant ratings.PNG

2 ACCEPTED SOLUTIONS

Accepted Solutions
Super User II
Super User II

Hi @Anonymous 

Collections only exist in computer memory and are lost when the app is closed.  If you have a gallery that is based on a collection, you must ClearCollect() the collection after making a change to the underlying data that the collection is based on.  While you can Patch() to a collection, the data is not saved anywhere unless you add it to the connected backend table. I suggest that you Patch() to the underlying data table, list or entity and then execute a ClearCollect() to recreate the collection. 

View solution in original post

Hi @Anonymous ,

 

After the collection is defined, it is stored in the cache. the cache is just temporary, like the variable, and all changes are lost when app is closed.

If you want to save the changed Collection, you should save the modification to the data source(CDS entity, SharePoint list, Excel or SQL) instead of a collection, or save the collection to local device and reload it when the app is opened.

Option1: store all data into a data source including a field to store the checkbox value. Bind the data source to the gallery, each time you check/uncheck the option, Patch the checkbox value to data source.

Option2: still use collection. patch the checkbox value to collection, and use SaveData function to save the collection into local device when the check box value is changed. Apply LoadData function to App.OnStart property  to Reloading the saved collection on next runs. Reference:SaveData and LoadData functions 

Hope this helps.

Sik

 

View solution in original post

2 REPLIES 2
Super User II
Super User II

Hi @Anonymous 

Collections only exist in computer memory and are lost when the app is closed.  If you have a gallery that is based on a collection, you must ClearCollect() the collection after making a change to the underlying data that the collection is based on.  While you can Patch() to a collection, the data is not saved anywhere unless you add it to the connected backend table. I suggest that you Patch() to the underlying data table, list or entity and then execute a ClearCollect() to recreate the collection. 

View solution in original post

Hi @Anonymous ,

 

After the collection is defined, it is stored in the cache. the cache is just temporary, like the variable, and all changes are lost when app is closed.

If you want to save the changed Collection, you should save the modification to the data source(CDS entity, SharePoint list, Excel or SQL) instead of a collection, or save the collection to local device and reload it when the app is opened.

Option1: store all data into a data source including a field to store the checkbox value. Bind the data source to the gallery, each time you check/uncheck the option, Patch the checkbox value to data source.

Option2: still use collection. patch the checkbox value to collection, and use SaveData function to save the collection into local device when the check box value is changed. Apply LoadData function to App.OnStart property  to Reloading the saved collection on next runs. Reference:SaveData and LoadData functions 

Hope this helps.

Sik

 

View solution in original post

Helpful resources

Announcements
New Badges

New Solution Badges!

Check out our new profile badges recognizing authored solutions!

New Power Super Users

Congratulations!

We are excited to announce the Power Apps Super Users!

Power Apps Community Call

Power Apps Community Call: February

Did you miss the call? Check out the Power Apps Community Call here.

Microsoft Ignite

Microsoft Ignite

Join digitally, March 2–4, 2021 to explore new tech that's ready to implement. Experience the keynote in mixed reality through AltspaceVR!

Top Solution Authors
Top Kudoed Authors
Users online (32,488)