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

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 Staff CarlosFigueira
Power Apps Staff

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 Staff cherie
Power Apps Staff

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 Staff CarlosFigueira
Power Apps Staff

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
Level: Powered On

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
Level: Powered On

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
Level: Powered On

Re: gallery list selection defaults to first screen on list

(Deleted comment)

Helpful resources

Announcements
New Ranks and Rank Icons in April

'New Ranks and Rank Icons in April

Read the announcement for more information!

Better Together’ Contest Finalists Announced!

'Better Together’ Contest Finalists Announced!

Congrats to the finalists of our ‘Better Together’-themed T-shirt design contest! Click for the top entries.

Power Platform 2019 release wave 2 plan

Power Platform 2019 release wave 2 plan

Features releasing from October 2019 through March 2020

thirdimage

Community Summit North America

Innovate, Collaborate, Grow - The top training and networking event across the globe for Microsoft Business Applications

Top Solution Authors
Top Kudoed Authors
Users online (10,017)