web
You’re offline. This is a read only version of the page.
close
Skip to main content
Community site session details

Community site session details

Session Id : K0VqSydD7aFaqAwrdSTQI6
Power Apps - Building Power Apps
Unanswered

Expand/Collapse for repeating gallery

Like (0) ShareShare
ReportReport
Posted on 7 Feb 2022 20:18:18 by

Hi all!

 

I have a repeating gallery (for a timecard) and I'm trying to expand/collapse some of the items in my gallery when I click a button. The only issue I'm running into is when I 'repeat' the gallery it's expanding/collapsing everything instead of the specific items relevant to that submission. 

 

As you can see in the picture, I want to expand/collapse each individual entry instead of all of the entries. The issue is I'm not sure how to set the visible property EACH SPECIFIC CONTROL instead of all the controls. 

 

Any help is greatly appreciated! 

 

Thank you!

  • RandyHayes Profile Picture
    76,287 Super User 2024 Season 1 on 07 Feb 2022 at 21:20:44
    Re: Expand/Collapse for repeating gallery

    @Anonymous 

    Actually, the LookUp function is excessive in this case and you can use:  ThisItem.ID in colExp instead.

  • RandyHayes Profile Picture
    76,287 Super User 2024 Season 1 on 07 Feb 2022 at 21:12:07
    Re: Expand/Collapse for repeating gallery

    @Anonymous 

    So, here is what you need to do.  I will use a collection method in this case even though it is a bit of an overkill.

     

    First, you WILL need a flexible height gallery!  There is no getting around that.

     

    Next, on the expand collapse icon, set the following:

    Icon -   If(LookUp(colExp, ID=ThisItem.ID, true), Icon.Collapse, Icon.Expand)

    OnSelect - If(LookUp(colExp, ID=ThisItem.ID, true), RemoveIf(colExp, ID=ThisItem.ID), Collect(colExp, {ID:ThisItem.ID}))

     

    Then, for the Visible property of the items in your gallery (and you can group them as @PowerRanger suggested, or reference them - i.e. One visible property controls the rest) set the property to: LookUp(colExp, ID=ThisItem.ID, true)

     

    That should give you what you need.

  • RandyHayes Profile Picture
    76,287 Super User 2024 Season 1 on 07 Feb 2022 at 21:07:33
    Re: Expand/Collapse for repeating gallery

    @PowerRanger 

    Groups are just fine (although annoying at times), but the common misunderstanding is that the "Group" is a control by itself that has a Visible, OnSelect, etc. on it...It does not, it is just a convenience to select a group and set a Visible, but it is NOT setting a Visible on a "Group" it is setting the visible on ALL of the control in the group.  

    The annoying part is that you can easily destroy existing formulas with that process.  So, if you had a control with a formula in the Visible property and then you grouped it with others and then set the Visible property on the "group" then you will be wiping out the existing Visible property on that particular control.

     

    But in the case of the gallery "real estate", even grouping them will not cause the gallery to change height unless it is in a flexible gallery.

     

  • SoPatt Profile Picture
    Microsoft Employee on 07 Feb 2022 at 21:03:46
    Re: Expand/Collapse for repeating gallery

    It was true given the qualifier "afaik" :D. I didn't know about the flexible height gallery. I'm glad to know about it now.

  • PowerRanger Profile Picture
    3,458 Super User 2024 Season 1 on 07 Feb 2022 at 21:03:28
    Re: Expand/Collapse for repeating gallery

    @RandyHayes You are totally right and I am absolutely aware of that. But to keep life easier I thought using a group here would make sense. 🙂

     

  • Community Power Platform Member Profile Picture
    on 07 Feb 2022 at 21:02:34
    Re: Expand/Collapse for repeating gallery

    Hey Randy! So I have a collection taking in all of these values.

     

    The reason the expand/collapse button is currently OUTSIDE of the gallery is because I couldn't get the expand/collapse function to work inside of the gallery. That being said I'm trying to move it into the gallery to make it work.

     

    What I was initially trying to do was to make the onvisible property look like this:

    Set(VarShowID, Sum(COLLECTION,ThisItem.ID)) and then the visible property for the controls (I.E. the group) was if(varShowID=Sum(COLLECTION,ThisItem.ID),true,false). I still am running into the issue of EVERYTHING expanding/collapsing instead of just the specific entry. 

     

    Also, see the image below for what I am attempting to make visible/unvisible. Thank you!

     

    PA3.PNG

  • RandyHayes Profile Picture
    76,287 Super User 2024 Season 1 on 07 Feb 2022 at 20:58:20
    Re: Expand/Collapse for repeating gallery

    @PowerRanger 

    Please keep in mind that there is no such thing as a "Group" in PowerApps.  When you Group your controls, you are just grouping them together in a convenient way.  So, while you think you might be setting the Visible property of the "Group" to something, you are really setting the Visible property of ALL the controls inside the group.  This is an important distinction!

    @Anonymous your issue is that you are trying to use a single variable to expand and collapse multiple rows of multiple records.  So, in a sense, you would need multiple variables.  That is not practical in PowerApps this way.  So utilizing a more elaborate variable or a collection (in-memory database) to determine expansion/collapse is needed.

    I am not seeing what it is that you want to expand or collapse as per the record/row of the gallery.  Your expand collapse is outside of the gallery, so it is assumed that you DO want to expand and collapse all items.

     

    As for the spacing in the gallery - you need to use a Flexible Height gallery for what you are trying to do.

     

    I hope this is helpful for you.

     

     

  • PowerRanger Profile Picture
    3,458 Super User 2024 Season 1 on 07 Feb 2022 at 20:52:03
    Re: Expand/Collapse for repeating gallery

    @Anonymous

    @sopatte that's not true.

     

    Steps to build something like you require:

     

    1. Use a Gallery "Blank flexible height"

    2. Try to build something like I did. Have a look at the tree view

    PowerRanger_0-1644266973163.png

    3. To Group controls you just select all controls you want to group, left cklick and Group

    PowerRanger_1-1644267037139.png

     

    4. Select the group and use this for the OnVisible property

    ThisItem.ID = varItemID

    5. On the button OnSelect use

    Set(varItemID,ThisItem.ID)

     

     

    Play the app and test it

     

    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.

  • Community Power Platform Member Profile Picture
    on 07 Feb 2022 at 20:34:32
    Re: Expand/Collapse for repeating gallery

    pa2.PNG

    pa1.PNG

     

    I'm running into the same issue - it expands and collapses all groups instead of just for each specific entry.

  • SoPatt Profile Picture
    Microsoft Employee on 07 Feb 2022 at 20:31:36
    Re: Expand/Collapse for repeating gallery

     I've wondered about this before. You can show or hide controls per item but afaik there is no way to have a gallery with varying heights per item. 

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

Telen Wang – Community Spotlight

We are honored to recognize Telen Wang as our August 2025 Community…

Announcing our 2025 Season 2 Super Users!

A new season of Super Users has arrived, and we are so grateful for…

Congratulations to the July Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Apps

#1
WarrenBelz Profile Picture

WarrenBelz 637 Most Valuable Professional

#2
stampcoin Profile Picture

stampcoin 570 Super User 2025 Season 2

#3
Power Apps 1919 Profile Picture

Power Apps 1919 473

Loading complete