Hello,
I have a tablet layout powerapp with one MyScreen. The Screen contains MyGallery, MyForm, CancelIcon and SubmitIcon. I like to select an Item in the MyGallery and edit in MyForm. When clicking the CancelIcon or SubmitIcon, the selection in MyGallery should be cleared.
I have it working except the Submit part. Once I submit an Item, I can't clear the Gallery selection anymore.
in MyScreen.OnVisible / MyScreen.OnHidden / CancelIcon.OnSelect, I use the following to clear the selection in MyGallery:
UpdateContext({MySelection: MyGallery.Selected}); UpdateContext({MySelection: {}})
To make this work, MyGallery is configured to
MyGallery.Default = MySelection
It seems to work like a charm. MyGallery shows all items but none is selected. When I select an item, it shows in MyForm by using
MyForm.Item = MyGallery.SelectedItem
When I click on the CancelIcon it resets MyGallery and the MyForm got nothing to show.
Once I submit the form using SubmitIcon.OnSelect:
SubmitForm( MyForm )
Now resetting the gallery doesn't work anymore, instead the last Submitted item is selected. Even if I select another item and click on CancelIcon, the last submitted item is selected.
Any suggestions how to make this work? Maybe a different approach?
Cheers,
Dennis
Solved! Go to Solution.
Hi
The only way of doing it is a bit drastic but it works however it also reset your form so you will have no items in the form. I would suggest you to get rid of the form, and make your own form with textinputs and labels items and use the patch function to edit the record. If you will have problem with doing that then let us know.
So to the point now... change your code in your cancel icon in OnSelect property
UpdateContext({reset:true}); UpdateContext({reset:false}); UpdateContext({MySelection: MyGallery.Selected}); UpdateContext({MySelection: {}})
Do the same thing in your MyScreen.OnVisible
Then in your gallery Items add this
If(reset=false,MyDataSourceName)
Obviously change the MyDataSourceName with the datasource you are using in your gallery
This will reset the whole gallery and make the deselecting code works again
Hi
The only way of doing it is a bit drastic but it works however it also reset your form so you will have no items in the form. I would suggest you to get rid of the form, and make your own form with textinputs and labels items and use the patch function to edit the record. If you will have problem with doing that then let us know.
So to the point now... change your code in your cancel icon in OnSelect property
UpdateContext({reset:true}); UpdateContext({reset:false}); UpdateContext({MySelection: MyGallery.Selected}); UpdateContext({MySelection: {}})
Do the same thing in your MyScreen.OnVisible
Then in your gallery Items add this
If(reset=false,MyDataSourceName)
Obviously change the MyDataSourceName with the datasource you are using in your gallery
This will reset the whole gallery and make the deselecting code works again
Hi Sienna,
I did an alternative way, by using a variable, e.g. SelectedGalleryItem, instead of Gallery.Selected. That has the disadvantage, that I have to iimplement the selection logic and the built-in selection logic doesn't work, e.g. Gallery.Selected and ThisItem.IsSelected.
Anyway ... Thanks a lot, your solution works for me. Resetting the form is not an issue, as I am hiding the form after it has been submitted. I did attach the reset-toggle only to the SubmitIcon and DeleteIcon, as only they caused that the MyGallery.Selected got stuck.
I think it can't be by design that submitting a form gets the Gallery.Selected misterically stuck. Is there a way to report this as a bug?
Cheers,
Dennis
User | Count |
---|---|
260 | |
109 | |
93 | |
57 | |
41 |