cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
SectorOMEGA
Helper IV
Helper IV

Checkbox control with separate button

Looking form some help with checkbox control if this is possible of course. I have a Gallery where Im showing some pictures in order user to match them with another one. I have a checkbox control which onCheck sets some variables and show Confirm button and on unCheck clears the variables and hides the confirm button. Is there any way to control the checkbox with normal button e.g. onSelect sets the variables and one more time onSelect clears the variables. Same as the checkbox control. Reason for asking is simple UI desgin which Im trying to achieve. Thank you in advance.

1 ACCEPTED SOLUTION

Accepted Solutions
Ethan_R
Continued Contributor
Continued Contributor

@SectorOMEGA ,

Use collection to track record changes.

For example,

UpdateContext({varToggle: !varToggle});
If(
   varToggle,
   Collect(
       colRecordsSelected,
       {
           ID: ThisItem.ID
       }
   ),
   Remove(
       colRecordsSelected,
       Filter(colRecordsSelected, ID = ThisItem.ID)
   )
);

This will mimic checkbox action.

 

only for proving that its working, checkbox will verify as 

Default property,

If(ThisItem.ID in colRecordsSelected.ID, true, false)

 

Ethan_R_0-1633943276925.png

Ethan_R_1-1633943291585.png

 

This will complete your steps.

 

View solution in original post

7 REPLIES 7
Ethan_R
Continued Contributor
Continued Contributor

Hi @SectorOMEGA ,

Use button instead, I've used the formula accordingly for OnSelect to execute both (check / uncheck) condition based on 1 variable.

for example,

//OnSelect property
UpdateContext({varToggle: !varToggle});
If(
   varToggle,
   <execute code if checked>,
   <execute code if unchecked>
);

For additional UX, use color Fill based on varToggle

 

Hope this helps

rampprakash
Memorable Member
Memorable Member

Hello @SectorOMEGA,

 

You can try below code

 

On Select of Button 

UpdateContext({showOrHideValues: !showOrHideValues});

 

To Clear a Collection

if(showOrHideValues,ClearCollect())

 

Then For Visible any select 

Put showOrHideValues in VISIBLE Property

 

Please mark as Answer if it is helpful and provide Kudos


Subscribe : https://www.youtube.com/channel/UCnGNN3hdlKBOr6PXotskNLA
Blog : https://microsoftcrmtechie.blogspot.com

 

 

Hi @Ethan_R Thanks for the response, but I have some issue with the code above. So in a gallery control Im adding a button and for its OnSelect property Im putting this as you suggested:

UpdateContext({varToggle: !varToggle}); 
If(varToggle,Select(Parent);
Set(varCurrentGuess, ThisItem.ID);
Set(varCheckBoxEnabled, false), 
Set(varCheckBoxEnabled, true));

 But its not working as intended. I have checkbox control for each item in the gallery(limited to 4 images only)

Hi, @rampprakash Im trying to combine the OnCheck and UnCheck properties with a single button. The visible part of a Confirm button is handled in the OnCheck and UnCheck property of the checkbox

Ethan_R
Continued Contributor
Continued Contributor

@SectorOMEGA ,

Use collection to track record changes.

For example,

UpdateContext({varToggle: !varToggle});
If(
   varToggle,
   Collect(
       colRecordsSelected,
       {
           ID: ThisItem.ID
       }
   ),
   Remove(
       colRecordsSelected,
       Filter(colRecordsSelected, ID = ThisItem.ID)
   )
);

This will mimic checkbox action.

 

only for proving that its working, checkbox will verify as 

Default property,

If(ThisItem.ID in colRecordsSelected.ID, true, false)

 

Ethan_R_0-1633943276925.png

Ethan_R_1-1633943291585.png

 

This will complete your steps.

 

View solution in original post

rampprakash
Memorable Member
Memorable Member

Hello @SectorOMEGA,

 

Cool, Click On App then On Start UpdateContext({showOrHideValues:false});

 

Consider showOrHideValues is false when page/App onStart

 

then on Click of Button (Onselect) we are calling UpdateContext({showOrHideValues: !showOrHideValues});

 

So what it will do it will change UpdateContext({showOrHideValues:true})

Again if you will click UpdateContext({showOrHideValues:false}) because we are using ! to give an opposite values of current Value.

 

So on First Click its True (which is Check box Selected) and Second Click Button is False( which is check box Unselected)

 

So for Visible property use showOrHideValues

 

 

Please mark as Answer if it is helpful and provide Kudos


Subscribe : https://www.youtube.com/channel/UCnGNN3hdlKBOr6PXotskNLA
Blog : https://microsoftcrmtechie.blogspot.com

 

 

Hi, @Ethan_R That did it! And one more small thing. Is there any way to avoid the need to double click on the button to mark it checked and to fully mimic the checkbox I need to be able to check only one and disable the rest. 
Im controlling this on the checkbox like this:

 

Set(varCheckBoxEnabled, false), 
Set(varCheckBoxEnabled, true));

The stangest thing is that if click on the checkbox its disabling the rest as per intended, but if use the button to fill the checkbox its not working(transfer the state of the variables to the checkbox)

 

Helpful resources

Announcements
UG GA Amplification 768x460.png

Launching new user group features

Learn how to create your own user groups today!

Community Connections 768x460.jpg

Community & How To Videos

Check out the new Power Platform Community Connections gallery!

M365 768x460.jpg

Microsoft 365 Collaboration Conference | December 7–9, 2021

Join us, in-person, December 7–9 in Las Vegas, for the largest gathering of the Microsoft community in the world.

Top Solution Authors
Top Kudoed Authors
Users online (3,158)