cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
Resolver I
Resolver I

Master toggle, with child toggle control

I've been racking my brain on this for a bit too long.  I have a form with a master toggle control (MT) that I want to control child toggles (CT) in a gallery.  If the MT is changed, I want all CT's to change. However, I want to retain the ability to toggle the CT's independently as well.  In the screen shot below, the top toggle is the MT, and the other's are CT's in a gallery (1 CT per record). 
1.png
The collection of the gallery contains the default value: ThisItem.IsPending.  I have this working today by using an UpdateIF statement: 
UpdateIf(PendingEquipmentCollection, StartDate = DateValue(TreeGallery.Selected.Entity), {IsPending: IsPendingMasterToggle.Value})

This all works, I can control the master, and child toggles independently since the collection is updated that the CT uses as a defalut value (ThisItem.Ispending). 

My issue: I've added a new textinput control and I've discovered that when the values are toggled since I'm updating the values in the collection, my textinput text is lost:

2.png

3.png

The check mark has new patch logic to save the comments, but they are wiped out by toggle changes. I've been trying to figure out how to control the toggles through variables, but can't seem to get my head wrapped around it since the CT's are inside a gallery and need to be able toggle independently from the MT.

Anyone have some thoughts on how I can accomplish this?

Thanks!

1 ACCEPTED SOLUTION

Accepted Solutions
Highlighted
Resolver I
Resolver I

Re: Master toggle, with child toggle control

I solved the issue by doing the following:

Created a variable conMasterToggleValue with a default value of false

 

Master Toggle.Default = conMasterToggleValue

Master Toggle.OnCheck = UpdateContext({conMasterToggleValue: true})

Master Toggle.OnUnCheck = UpdateContext({conMasterToggleValue: false})

 

Child Toggle: If(conMasterToggleValue = false, !ThisItem.IsPending, conMasterToggleValue)

 

This allowed independent control of the toggles, and the user could click save which then wrote the textbox/toggle control values to a collection.

View solution in original post

4 REPLIES 4
Highlighted
Community Support
Community Support

Re: Master toggle, with child toggle control

@MikeAnderson 

 

There are two workaround:

1. save the text into collection once it is entered

2. just change the toggle value, and use the check icon to save the toggle value to collection.

 

1.

Set the following codes to OnChange property of Textinput box in gallery:

Patch(PendingEquipmentCollection, ThisItem, {TextColumn: TextInput1.Text})

Snipaste_2020-02-04_15-19-04.png

2.

Set the Main Toggle OnChange property: Set(Var1,MT.Value) 

Set the CT Default property: If(IsBlank(Var1),IsPending,Var1)Snipaste_2020-02-04_15-18-57.png

Sik

 

Highlighted
Resolver I
Resolver I

Re: Master toggle, with child toggle control

Hi  v-siky-msft,

 

Unfortunately #2 doesn't work, as it doesn't allow independent toggling of the child toggles.  This was the original issue I ran into.  If you set the child toggles to the master toggle value, you lose the ability to change the child toggle values.  The reason I need this level of control is in the gallery there might be 10 records showing, and 9 of the 10 need to be the same value as the master toggle.  But one of the records does not.  So, toggle master to set all, and then unchecking the one record is what the user wants.  

 

PS: Love the images you used 😉

Highlighted
Community Support
Community Support

Re: Master toggle, with child toggle control

Ok @MikeAnderson 

What about the first workaround.

Does it make sense for your case?

Sik

Highlighted
Resolver I
Resolver I

Re: Master toggle, with child toggle control

I solved the issue by doing the following:

Created a variable conMasterToggleValue with a default value of false

 

Master Toggle.Default = conMasterToggleValue

Master Toggle.OnCheck = UpdateContext({conMasterToggleValue: true})

Master Toggle.OnUnCheck = UpdateContext({conMasterToggleValue: false})

 

Child Toggle: If(conMasterToggleValue = false, !ThisItem.IsPending, conMasterToggleValue)

 

This allowed independent control of the toggles, and the user could click save which then wrote the textbox/toggle control values to a collection.

View solution in original post

Helpful resources

Announcements
secondImage

Demo-Extravaganza 2020

Check out these cool Power Apps & vote on your favorite!

secondImage

Community Highlights

Check out whats happening in Power Apps

secondImage

Community User Group Member Badges

FIll out a quick form to claim your community user group member badge today!

secondImage

Power Platform 2020 release wave 2 plan

Features releasing from October 2020 through March 2021

Top Solution Authors
Top Kudoed Authors
Users online (10,294)