cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Leonie Helper I
Helper I

gallery list selection defaults to first screen on list

My Gallery list selection defaults to show the first screen on list, not the one selected, then when you click another item in the gallery list, it goes to the screen of your previous selection.

 

e.g. I select "Cleaning" and the next screen shown is the first one for "Good Better Best", then when I select another menu item, e.g. "Barware", it will show the last one chosen which was "Cleaning" If I select another menu item it will then show "Barware", etc etc.  Essentially you have to click on the Gallery list item twice to get to the screen you actually want to view.

 

menu.png

 

I am using ClearCollect on the Menu screen (above)

 

ClearCollect(Screens,{Name:"GBB",Target:GBB},{Name:"Bakery",Target:Bakery},{Name:"Barware",Target:Barware},{Name:"Cleaning",Target:Cleaning},{Name:"Coffee",Target:Coffee},{Name:"Cooking",Target:Cooking},{Name:"Crockery",Target:Crockery},{Name:"Cutlery",Target:Cutlery},{Name:"DisplayCabinets1",Target:DisplayCabinets1},{Name:"Displayware",Target:Displayware1},{Name:"Furniture",Target:Furniture},{Name:"Kitchenware",Target:Kitchenware1},{Name:"MealDistribution",Target:MealDist},{Name:"Refrigeration",Target:Refrigeration},{Name:"Stainless",Target:Stainless},{Name:"Storage",Target:Storage1},{Name:"Tabletop",Target:Tabletop1},{Name:"Uniforms",Target:Uniforms})

 

and for the OnSelect action: 

 

Navigate(LookUp(Screens,Name = Gallery1.Selected.ScreenRef,Target),None)

 

ScreenRef is referenced in my Sharepoint list and the Target is the name of the screen.

 

Any ideas on why it's doing this and how I can fix it?

1 ACCEPTED SOLUTION

Accepted Solutions
Power Apps
Power Apps

Re: gallery list selection defaults to first screen on list

You can try using the ThisItem operator instead of the gallery selection to decide which screen to navigate to.

Navigate(LookUp(Screens,Name = ThisItem.ScreenRef,Target),None)

The issue is that when you click on the right arrow, two actions happen: the gallery selection is changed, and the OnSelect property of the arrow is executed. There is no guarantee which one will be executed first (and I've observed that it happens differently in multiple platforms), so what you're seeing is probably the OnSelect is being executed before the selection change. By using the ThisItem operator, you guarantee that you're choosing the item from the corresponding row in the gallery.

View solution in original post

5 REPLIES 5
Power Apps
Power Apps

Re: gallery list selection defaults to first screen on list

Hi,

 

You could add a switch statement to the OnSelect.

 

Something like this

 

Switch(
  Gallery1.Selected.ScreenRef,
  "GBB",Navigate(GBB, Fade),
  "Bakery",Navigate(Bakery, Fade)
)

 

Thanks

Cherie

 

Power Apps
Power Apps

Re: gallery list selection defaults to first screen on list

You can try using the ThisItem operator instead of the gallery selection to decide which screen to navigate to.

Navigate(LookUp(Screens,Name = ThisItem.ScreenRef,Target),None)

The issue is that when you click on the right arrow, two actions happen: the gallery selection is changed, and the OnSelect property of the arrow is executed. There is no guarantee which one will be executed first (and I've observed that it happens differently in multiple platforms), so what you're seeing is probably the OnSelect is being executed before the selection change. By using the ThisItem operator, you guarantee that you're choosing the item from the corresponding row in the gallery.

View solution in original post

Leonie Helper I
Helper I

Re: gallery list selection defaults to first screen on list

awesome, that worked!  Thank you, a nice simple answer and thanks for explaining the reason too.

Leonie Helper I
Helper I

Re: gallery list selection defaults to first screen on list

Thanks for the first idea, I did try this and it didn't work, but the next solution did work ok

vwyankee Advocate II
Advocate II

Re: gallery list selection defaults to first screen on list

(Deleted comment)

Helpful resources

Announcements
MBAS Gallery 2020

MBAS Gallery 2020

Watch Microsoft Business Applications Summit sessions on-demand.

firstImage

New Ranks and Rank Icons released on April 21!

The time has come: We are finally able to share more details on the brand-new ranks coming to the Power Apps Community!

Top Solution Authors
Top Kudoed Authors
Users online (7,034)