cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
MiracleMan
Frequent Visitor

Select single checkbox inside a Gallery

I have a gallery that show different alternatives for the user to select one. These options comes from another table.  I would like to make the checkbox in a way that user can only select one.  None of the methods I saw worked for me. Any suggestions?

1 ACCEPTED SOLUTION

Accepted Solutions
v-siky-msft
Community Support
Community Support

Hi @MiracleMan ,

 

You can achieve the single checkbox by a Gallery.

 

First, add a nested gallery2 inside the gallery1, set the Gallery2.Items to another table you mentioned. Then add a checkbox into gallery2, set Text property to ThisItem.ColumnName.

 

Next, configure the single-check function. Since the gallery can only be single-selected, set Checkbox.Default property: ThisItem.IsSelected, when the gallery item is selected, the checkbox is also checked. 

 

However, It was found in the test that there were some conflicts between checkbox and Gallery Item, it didn't work as expected.

The workaround is here: Add a Blank Label into Gallery2, to be front of the checkbox, And set the Visible property: !ThisItem.IsSelected || !Checkbox1.Value. Use Label to avoid the selection conflict between the checkbox and Gallery Item. 

Here we go.

GIF_77.gif

Hope this helps.

Sik

 

View solution in original post

9 REPLIES 9
Drrickryp
Super User
Super User

Can it be done with a Radio control? I tried but I wasnt able to figure out how the assign the field to the radio.

 

Also, I did the radio thing (living the default text) and it allowed me to click all of them.

@MiracleMan 

You would do it similar to how you use a dropdown control, either hard code the choices like ["Choice1", "Choice2", etc] or you can use Distinct(yourdatasource, yourselectedcolumn) as the Items property.  If you are using it to display choices in a Gallery, set the Default property of the Radio control to the Item as

 

 LookUp(yourdatasource, ID = ThisItem.ID, yourselectedcolumn)

 

Annotation 2020-06-01 121046.png

v-siky-msft
Community Support
Community Support

Hi @MiracleMan ,

 

You can achieve the single checkbox by a Gallery.

 

First, add a nested gallery2 inside the gallery1, set the Gallery2.Items to another table you mentioned. Then add a checkbox into gallery2, set Text property to ThisItem.ColumnName.

 

Next, configure the single-check function. Since the gallery can only be single-selected, set Checkbox.Default property: ThisItem.IsSelected, when the gallery item is selected, the checkbox is also checked. 

 

However, It was found in the test that there were some conflicts between checkbox and Gallery Item, it didn't work as expected.

The workaround is here: Add a Blank Label into Gallery2, to be front of the checkbox, And set the Visible property: !ThisItem.IsSelected || !Checkbox1.Value. Use Label to avoid the selection conflict between the checkbox and Gallery Item. 

Here we go.

GIF_77.gif

Hope this helps.

Sik

 

Hi @v-siky-msft ,

 

I have gone through your solution it's working in a way but for selecting one checkbox its taking  two mouse clicks. Could you please help me on this.

 

Thanks in advance.

by fault I am getting 1 checkbox as checked. I want to have all checkbox as unchecked by default. Can you please guide me how to achieve this.

How to use one checkbox at a time inside the Gallery. If i choose one among two checkboxes, other box should be unchecked automatically.

Adi199
Frequent Visitor

Hi @v-siky-msft Your solution work just fine but now the OnCheck and OnUncheck property of check box is not working at all

Your solution work just fine but now the OnCheck and OnUncheck property of check box is not working at all. If the checkbox is checked i need to collect the checked item into check box but when i check the check box its value flip to true but collection is not collecting any value. Can you help ? 

For Further details see :https://powerusers.microsoft.com/t5/Building-Power-Apps/Checkbox-On-Check-and-On-Un-Check-in-nested-... 

Helpful resources

Announcements
Power Apps News & Annoucements carousel

Power Apps News & Announcements

Keep up to date with current events and community announcements in the Power Apps community.

Community Call Conversations

Introducing the Community Calls Conversations

A great place where you can stay up to date with community calls and interact with the speakers.

Power Apps Community Blog Carousel

Power Apps Community Blog

Check out the latest Community Blog from the community!

Top Solution Authors
Top Kudoed Authors
Users online (2,607)