cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
SebastianG
Level: Powered On

Re: How Can I Clear a Gallery Selection

Hi,

 

did you find the solution? I have this same problem Smiley Sad

 

Cheers

Sebastian

Dawidvh
Level 10

Re: How Can I Clear a Gallery Selection

Hi everyone,

 

I realize this will not an option for all scenarios, but the most effective way that we have found for the gallery to 'forget' which item was selected, or even that something was selected is, by clearing the data source Smiley Surprised

 

a) Set gallery.default = {}

b) If gallery.items contains a collection, clear the collection on form onvisible or from whatever is calling the form. If you use ClearCollect, this will not reset the gallery, because it doesn't seem to put the gallery in a state where it doesn't contain any items at any stage, which is what causes the gallery to reset the selection.

 

I haven't tried the above with other datasources, to possibly set the gallery.items property to something like [{ }] during certain triggers, but this might be worth trying.

 

JeremyDIV
Level: Powered On

Re: How Can I Clear a Gallery Selection

In what world is that "Easy?"

 

There should not have to be a workaround for every little piece of basic functionality but it seems that is what powerapps make us do. Having to use Context variables to do anything useful drives me nuts.

 

This is broken! ... It should be fixed!

Highlighted
Mike8
Level 10

Re: How Can I Clear a Gallery Selection

Hello,@JeremyDIV I agree with you. Some things should be simpler.
@Dawidvh is right. You need to "refresh" the items, but there no need to clear the collection.

If you need to refresh the gallery in order not to have selected item you can do these:

Solution1: If you need only one button that triggers the refresh,

Gallery1.Default = {}                                                                    (as Dawidvh said)
Gallery1.Items = If(!Button1.Pressed,Collection1)                       (notice the !   It's !Button1.Pressed)
This way whenever Button1 is pressed it goes, false true, and it's like the Items in the gallery are reseting

Solution 2 that is more generic,

Gallery1.Default = vDefaultGallery 
and whenever you want to refresh the selection of the gallery, in our case Button1, add this:
Button1.OnSelect = UpdateContext({vDefaultGallery :Blank()});UpdateContext({vDefaultGallery :{}})

I

Helpful resources

Announcements
firstImage

Watch Sessions On Demand!

Continue your learning in our online communities.

SecondImage

PowerApps Monthly Community Call

Next Wednesday, September 18th at 8am PDT

Power Platform 2019 release wave 2 plan

Power Platform 2019 release wave 2 plan

Features releasing from October 2019 through March 2020

FirstImage

Power Platform World Tour

Coming to a city near you

thirdimage

PowerApps Community User Group Member Badge

Fill out a quick form to claim your user group badge now!

FourthImage

Join PowerApps User Group!!

Connect, share, and learn with your peers year-round

SecondImage

Power Platform Summit North America

Register by September 5 to save $200

Top Kudoed Authors
Users Online
Currently online: 225 members 4,683 guests
Please welcome our newest community members: