cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Kosenurm
Post Partisan
Post Partisan

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
Tushya_Trivedi
Helper I
Helper I

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 Platform Conf 2022 768x460.jpg

Join us for Microsoft Power Platform Conference

The first Microsoft-sponsored Power Platform Conference is coming in September. 100+ speakers, 150+ sessions, and what's new and next for Power Platform.

PA Virtual Workshop Carousel 768x460.png

Register for a Free Workshop

This training provides practical hands-on experience in creating Power Apps solutions in a full-day of instructor-led App creation workshop.

PA.JPG

New Release Planning Portal (Preview)

Check out our new release planning portal, an interactive way to plan and prepare for upcoming features in Power Platform.

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