cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Kosenurm
Super User
Super User

Urgent - Select and deselect multiple checkboxes on toggle

Hi there,

 

I have a screen in my canvas app where I have a toggle to select-all checkboxes on that screen. 

 

OnVisible of the page, I have created the collection of allboxes using Collect(allboxes, 'checkbox1'.Value, 'checkbox2'.Value);   (I will add in the other 5 checkboxes once I've got this working).

 

What I want is, when the user turns the toggle to Yes, it ticks all the checkboxes which are in that collection. 

 

Please can someone help me out here?

 

Thanks, 

K. 

1 ACCEPTED SOLUTION

Accepted Solutions

Hi @Kosenurm ,
I believe your checkboxes are independent. If I got you correctly, your set is something like the below screenshot.

on right side, I am trying to show the values reflected in coll_result based on my selection. 

Abhilash_Swain_0-1643046055067.png

Abhilash_Swain_1-1643046139487.png

 

Abhilash_Swain_2-1643046183377.png

Give a like and accept this as the solution if I answered you . 🙂 

View solution in original post

15 REPLIES 15

In the Onselect Property of the toggle you can apply ForAll for all the items in the collection and change their values

C-Papa
Super User
Super User

hi, create the collection in the following way

Collect(Col_Toggles,{value:Toggle1} etc.)

 

then change the toggle defaults to

Self in Col_Toggles && var_toggle

 

OnSelect of button change to all toggles

Set(var_toggle, !var_toggle)

 

Thanks, but this is for Check Boxes...

 

Which value of the checkbox control should I add to the collection?

Tushya_Trivedi_0-1643033050679.png

Tushya_Trivedi_1-1643033067808.png

 

take the default property of the checkbox

Abhilash_Swain
Super User
Super User

Hi @Kosenurm ,

I have a similar setup, but in a Lil different format as shown below screenshot. By selecting the checkbox on top, it selects all and, on deselect, it marks all as cleared.

Abhilash_Swain_1-1643032192389.png

Let's say your source is source1.

Step -1 :-
> On page load, ClearCollect(coll_GalDisplay,AddColumns(Source1,"ischecked",false)) this will create a collection "coll_GalDisplay" which we are going to use in gallery to display.
The new column added, ischecked will contain the value of checked Items.

> 2nd create a toggle/ separate check box (Marked in red in screen shot)
Property - OnCheck- Updateif(coll_GalDisplay,true,{ischecked: true})
Property - OnUncheck - Updateif(coll_GalDisplay,true,{ischecked: false})

 

For individual check boxes to select, or unselect, 

Abhilash_Swain_2-1643032868296.png

Property - OnCheck- Patch(coll_GalDisplay,,ThisItem,{ischecked:true})
Property - OnUncheck - Patch(coll_GalDisplay,,ThisItem,{ischecked:true})

 

Please give a like and accept this as the solution if this will help in your requirement.

Thanks. I think you are on the right path. 

 

What I need is...

 

When the user selects one of the checkboxes, this adds to a collection. If they add more than one, they are all added. If they uncheck one, or uncheck more than one, the collection is updated to their new check statuses. 

 

The toggle needs to set ALL checkboxes to checked OnCheck, and decheck ALL checkboxes OnUncheck...

 

Sorry, I am really struggling.

 

Thanks

K.

Abhilash_Swain
Super User
Super User

Could you please try On check property for an individual item,

Property - OnCheck- Patch(coll_GalDisplay,,ThisItem,{ischecked:true});
Collect(coll_result, ThisItem);


Property - OnUncheck - Patch(coll_GalDisplay,,ThisItem,{ischecked:true});
Remove(coll_result, ThisItem);

 

At the end, your collection "coll_result" will have the final list of items that you have selected for your next action.

I am not using a gallery, so ThisItem is not working.

 

K.

If you are trying to collect it from a collection, I will suggest to add a button called "load".

So once you are clear with your selection, Click the load button to collect the selected values.

 

Load Button- Property "On Select"- ClearCollect(Coll_result,Filter(allboxes, ischeked = true)).

It will load all the items from allboxes collection to result collection where the condition satisfies.

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.

Microsoft 365 Conference – December 6-8, 2022

Microsoft 365 Conference – December 6-8, 2022

Join us in Las Vegas to experience community, incredible learning opportunities, and connections that will help grow skills, know-how, and more.

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 (4,130)