Skip to main content

Notifications

Community site session details

Community site session details

Session Id : zai/OZEJauxc3lfx4pJJ4r
Power Apps - Building Power Apps
Unanswered

Problem with checkbox in nested gallery - Canvas app

Like (0) ShareShare
ReportReport
Posted on 15 Mar 2023 03:30:04 by 30

Hi,

 

I have implemented nested gallery concept in Canvas PowerApps.
1. I have checkbox (Select All) added on my parent gallery
2. I have checkbox (Select single) added on my child gallery
3. I have passed "Parent_checkbox.value" to Default property of "Child_checkbox"
4. When I select "Parent_checkbox" then automatically it selects all "Child_checkbox"
5. When I uncheck "Parent_checkbox" then automatically it uncheck all "Child_checkbox"

Till here it is working as expected.

Now, when I will uncheck any one of the "Child_checkbox" then it should uncheck it's "Parent_checkbox".
I tried many ways to implement it but it is not working.

  • nsmarathe Profile Picture
    30 on 16 Mar 2023 at 04:09:56
    Re: Problem with checkbox in nested gallery - Canvas app

    Did you get any solution?

  • SoPatt Profile Picture
    Microsoft Employee on 15 Mar 2023 at 09:17:52
    Re: Problem with checkbox in nested gallery - Canvas app

    I did find some behavior that wasn't right, namely that when one of the child checks was unchecked, it would uncheck all of them. Odd that it was not the same as what you found. I updated my solution but there it's still not quite right as all parent gallery rows reset at the same time.

  • nsmarathe Profile Picture
    30 on 15 Mar 2023 at 08:51:11
    Re: Problem with checkbox in nested gallery - Canvas app

    Not working

  • nsmarathe Profile Picture
    30 on 15 Mar 2023 at 08:28:35
    Re: Problem with checkbox in nested gallery - Canvas app

    Yes. I have it but instead of  lblID.Text=ThisItem.ID I am taking lblID.Text=ThisItem.country as a unique identifier 

  • SoPatt Profile Picture
    Microsoft Employee on 15 Mar 2023 at 08:15:28
    Re: Problem with checkbox in nested gallery - Canvas app

    Also do you have lblID with Text=ThisItem.ID in ParentGallery?

  • SoPatt Profile Picture
    Microsoft Employee on 15 Mar 2023 at 07:57:47
    Re: Problem with checkbox in nested gallery - Canvas app

    In my tests it did all that. Try Reset(Child_checkbox) at the end of both Parent_checkbox.OnUncheck and Parent_checkbox.OnCheck

  • nsmarathe Profile Picture
    30 on 15 Mar 2023 at 07:38:33
    Re: Problem with checkbox in nested gallery - Canvas app

    Thanks for sharing the solution.

    I have implemented your solution and it is working to check/uncheck parent checkbox based on selection of child checkbox. Below things stopped working now:

    1. When check parent checkbox all child checkboxes should be checked

    2. When uncheck parent checkbox all child checkboxes should be unchecked

     

    So the solution which you have provided, it should work along with above 2 points. I am trying to fix the problem.

    Please let me know if you get any solution to fix it.

  • nsmarathe Profile Picture
    30 on 15 Mar 2023 at 05:54:17
    Re: Problem with checkbox in nested gallery - Canvas app

    Thanks for providing a solution. I will try it and let you know.

  • SoPatt Profile Picture
    Microsoft Employee on 15 Mar 2023 at 05:52:39
    Re: Problem with checkbox in nested gallery - Canvas app

    My Solution from a few minutes ago follows this same concept, combined with the other solution you had referenced and a little improvement of my own.

  • SoPatt Profile Picture
    Microsoft Employee on 15 Mar 2023 at 05:48:12
    Re: Problem with checkbox in nested gallery - Canvas app

    First, add a label called lblID to your parent gallery, and make sure its Text property is set to ThisItem.ID (or whatever unique identifier for the record). Possibly set its Visible property to false if desired.

    Screen.OnVisible:

     

     

    Collect(
     MyChecks,
     {
     ID: -1,
     Value: false
     }
    );
    Clear(MyChecks)

     

     

    Parent_checkBox.OnCheck:

     

     

    UpdateContext({Resetting:true});
    With({
     MyCheck: LookUp(
     MyChecks,
     ID = ThisItem.ID
     )
    },
     Patch(
     MyChecks,
     MyCheck,
     {
     ID:ThisItem.ID,
     Value:true
     }
     )
    );
    UpdateContext({Resetting:false})

     

     

    Parent_checkbox.OnUncheck:

     

     

    UpdateContext({Resetting:true});
    With({
     MyCheck: LookUp(
     MyChecks,
     ID = ThisItem.ID
     )
    },
     Patch(
     MyChecks,
     MyCheck,
     {
     ID:ThisItem.ID,
     Value:false
     }
     )
    );
    UpdateContext({Resetting:false})

     

     

    Parent_checkbox.Default:

     

     

    !(false in Concat(ChildGallery.AllItems,Child_checkbox.Value))
    // substitute your child gallery name

     

     

    Child_checkbox.OnUncheck:

     

     

    Reset(Parent_checkbox)

     

     

    Child_checkbox.Default:

     

     

    With({
     MyID:Value(lblID.Text)
    },
     LookUp(
     MyChecks,
     ID = MyID,
     Value
     )
    )

     

     

    Child_checkbox.Reset:

     

    Resetting

     

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Understanding Microsoft Agents - Introductory Session

Confused about how agents work across the Microsoft ecosystem? Register today!

Warren Belz – Community Spotlight

We are honored to recognize Warren Belz as our May 2025 Community…

Congratulations to the April Top 10 Community Stars!

Thanks for all your good work in the Community!

Leaderboard

#1
WarrenBelz Profile Picture

WarrenBelz 146,786 Most Valuable Professional

#2
RandyHayes Profile Picture

RandyHayes 76,287 Super User 2024 Season 1

#3
Pstork1 Profile Picture

Pstork1 66,093 Most Valuable Professional

Leaderboard