cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Anonymous_Hippo
Resolver I
Resolver I

How to select only one item inside a gallery which is embedded within another gallery

Hello ! 

 

I am trying to build a tabular view in PowerApps using a gallery embedded (gallery2) within another gallery(gallery1). But I want to be able to select a single record inside the embedded gallery (gallery2)

 

I have highlighted gallery1 in yellow and gallery2 in red

Anonymous_Hippo_0-1628609841447.png

 

For example if i select 6 then only 6 should be selected and all other values selected inside gallery2 must be unselected.

 

Normally a user can select only one record per gallery but since i have embedded a gallery inside another gallery it becomes complicated

1 ACCEPTED SOLUTION

Accepted Solutions
RandyHayes
Super User
Super User

@Anonymous_Hippo 

You will not be able to have an empty selection on the Gallery.  If there is no specific selection, then the first item will always be selected.

You will need to do some tricky workarounds for this to work as you want.  Essentially, you will not be relying on the Selected property of the gallery but instead capturing the selection and then comparing.

 

Example, your OnSelect of the nested gallery would be : UpdateContext({lclSelection: ThisItem.ID})

Then, your TemplateFill property would be:

    If(ThisItem.ID = lclSelection, LightSteelBlue, Transparent)

 

And, when you go to see what is "really" selected, you would refer to the snapshot variable, lclSelection, to get it - not the Gallery itself.

 

I hope this is helpful for you.

_____________________________________________________________________________________
Digging it? - Click on the Thumbs Up below. Solved your problem? - Click on Accept as Solution below. Others seeking the same answers will be happy you did.
Check out my PowerApps Videos too! And, follow me on Twitter @RandyHayes

Really want to show your appreciation? Buy Me A Cup Of Coffee!

View solution in original post

1 REPLY 1
RandyHayes
Super User
Super User

@Anonymous_Hippo 

You will not be able to have an empty selection on the Gallery.  If there is no specific selection, then the first item will always be selected.

You will need to do some tricky workarounds for this to work as you want.  Essentially, you will not be relying on the Selected property of the gallery but instead capturing the selection and then comparing.

 

Example, your OnSelect of the nested gallery would be : UpdateContext({lclSelection: ThisItem.ID})

Then, your TemplateFill property would be:

    If(ThisItem.ID = lclSelection, LightSteelBlue, Transparent)

 

And, when you go to see what is "really" selected, you would refer to the snapshot variable, lclSelection, to get it - not the Gallery itself.

 

I hope this is helpful for you.

_____________________________________________________________________________________
Digging it? - Click on the Thumbs Up below. Solved your problem? - Click on Accept as Solution below. Others seeking the same answers will be happy you did.
Check out my PowerApps Videos too! And, follow me on Twitter @RandyHayes

Really want to show your appreciation? Buy Me A Cup Of Coffee!

View solution in original post

Helpful resources

Announcements
User Group Leader Meeting January 768x460.png

Calling all User Group Leaders!

Don't miss the User Group Leader meetings on January, 24th & 25th, 2022.

Community Connections 768x460.jpg

Community & How To Videos

Check out the new Power Platform Community Connections gallery!

Top Solution Authors
Top Kudoed Authors
Users online (1,834)