cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Sesese
Helper II
Helper II

How to manage checkboxes individually and with a select/unselect all?

Hey guys,

 

in my app I have a gallery with a checkbox in it, one for each row.

Before opening this thread https://powerusers.microsoft.com/t5/Building-Power-Apps/Select-all-Unselect-all-checkboxes-with-a-cl... I was used to manage them easily one by one whit this set up:

 

Reset: varResetCheckbox

Default: ThisItem.Selezionato

OnSelect: UpdateContext({varResetCheckbox: true});;UpdateContext({varResetCheckbox: false})

OnCheck: Patch(collectionFlotta_Anag; ThisItem; {Selezionato: true})

OnUncheck: Patch(collectionFlotta_Anag; ThisItem; {Selezionato: false})

 

Now, applying the rules defined in the above link, I can easily manage the select/unselect all but I can't manage one by one cause the check element disappear once is the box is clicked

 

Can someone help me?

 

Tx

6 REPLIES 6
theapurva
Super User
Super User

Hello,
Please try putting as below:

 

For Parent Checkbox(Heading row):
OnCheck: UpdateContext({varResetCheckbox:true})
OnUnCheck: UpdateContext({varResetCheckbox:false})

Default: false

Reset:false

 

For Items Checkbox:

Reset: false

Default: varResetCheckbox

OnSelect: false

OnCheck: Patch(collectionFlotta_Anag; ThisItem; {Selezionato: true})

OnUncheck: Patch(collectionFlotta_Anag; ThisItem; {Selezionato: false})

----------------------------------------------------------------------------------------------------------------------
Please 'Mark as Solution' if someone's post answered your question and always 'Thumbs Up' the posts you like or that helped you!
Sesese
Helper II
Helper II

Which is the difference between Parent & Items checkbox?

theapurva
Super User
Super User

Whenever Parent checkbox is checked, All the items will be checked,

and when Parent checkbox is Unchecked, All the items will be Unchecked,

theapurva_0-1657111257470.png

 

So use the setting as:

For Parent Checkbox(Heading row):
OnCheck: UpdateContext({varResetCheckbox:true})
OnUnCheck: UpdateContext({varResetCheckbox:false})

Default: false

Reset:false

 

For Items Checkbox:

Reset: false

Default: varResetCheckbox

OnSelect: false

OnCheck: Patch(collectionFlotta_Anag; ThisItem; {Selezionato: true})

OnUncheck: Patch(collectionFlotta_Anag; ThisItem; {Selezionato: false})

----------------------------------------------------------------------------------------------------------------------
Please 'Mark as Solution' if someone's post answered your question and always 'Thumbs Up' the posts you like or that helped you!

This is my gallery actually:

 

Diapositiva1.PNG

 

In the checkbox I've put the rules in the first message.

Then I've changed Default from ThisItem.Selezionato to varChecked and crated one button with UpdateContext({varChecked: true}) and another with UpdateContext({varChecked: false})

WarrenBelz
Super User
Super User

Hi @Sesese ,

You actually cannot have it both ways here entirely as you need the Default to show the current value in Selezionato, however if you put a "master" checkbox outside the gallery (I have called it ckMaster below), you can do a "Select All" which will work and when unchecked will revert to the value in the field. You do not need any resets here - use your existing code except the Default of the checkbox in the gallery can be

ckMaster.Value || ThisItem.Selezionato

You can also reduce your Patch code a bit - OnSelect (you do not need the OnCheck and OnUncheck) of the checkbox in the gallery

Patch(
   collectionFlotta_Anag; 
   ThisItem; 
   Self.Value
)

 

Please click Accept as solution if my post helped you solve your issue. This will help others find it more readily. It also closes the item. If the content was useful in other ways, please consider giving it Thumbs Up.

Visit my blog Practical Power Apps

 

 

 

WarrenBelz
Super User
Super User

Hi @Sesese ,

Just checking if you got the result you were looking for on this thread. Happy to help further if not.

Please click Accept as solution if my post helped you solve your issue. This will help others find it more readily. It also closes the item. If the content was useful in other ways, please consider giving it Thumbs Up.

Visit my blog Practical Power Apps

Helpful resources

Announcements
Ignite 2022

WHAT’S NEXT AT MICROSOFT IGNITE 2022

Explore the latest innovations, learn from product experts and partners, level up your skillset, and create connections from around the world.

Power Apps Africa Challenge 2022

Power Apps Africa Challenge

Your chance to join an engaging competition of Power Platform enthusiasts.

Super User 2 - 2022 Congratulations

Welcome Super Users

The Super User program for 2022 - Season 2 has kicked off!

September Events 2022

Check out all of these events

Attend in person or online, there are incredible conferences and events happening all throughout the month of September.

Users online (1,983)