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

Announcements

News and Announcements icon
Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Apps / how do i collapse a bu...
Power Apps
Answered

how do i collapse a button in a gallery

(0) ShareShare
ReportReport
Posted on by 403

Jupyter123_0-1669014333415.png

 

check out that above image

whenever i click other buttons below, the previous one gets collapsed

but when i click the first button, it is not getting collapsed 

So, what i want is, whenever i click on a exisiting button, that existing button should get collapsed

if i click "what is covid 19" button, then the exisiting button should be collapsed

hope my question is clear 🙂

Categories:
  • Verified answer
    v-xiaochen-msft Profile Picture
    Microsoft Employee on at

    Hi @Jupyter123 ,

     

    I made a sample for you:

     

    This is the data source, including Title and a text column.

    vxiaochenmsft_0-1669094718982.png

     

     

    Create the following gallery.

    vxiaochenmsft_1-1669094718984.png

     

     

    Here is the property 'OnSelect' of the control 'expend'.

    UpdateContext({expandCollapse:true})

    vxiaochenmsft_2-1669094718986.png

     

     

    Below is the property 'Visible' of the control 'expend'

    Not(expandCollapse && ThisItem.IsSelected)

    vxiaochenmsft_3-1669094718988.png

     

     

    Here is the property 'OnSelect' of the control ‘collaspe'

    UpdateContext({expandCollapse:false})

    vxiaochenmsft_4-1669094718990.png

     

     

    Below is the property 'Visible' of the control 'collaspe'

    expandCollapse && ThisItem.IsSelected

    vxiaochenmsft_5-1669094718992.png

     

     

    Set the height of the control ‘Description’.

    If(expandCollapse && ThisItem.IsSelected,100,0)

    vxiaochenmsft_6-1669094718994.png

     

     

    Click the 'Collapse' or 'Expand' button and the current item will be collapsed or expanded.

    vxiaochenmsft_7-1669094718995.png

     

    vxiaochenmsft_8-1669094718995.png

    Best Regards,

    Wearsky

  • Jupyter123 Profile Picture
    403 on at

    @v-xiaochen-msft  perfect solution , it works but if the user clicks the icon then it gets expanded but sometimes the user clicks the button (title) , so in that case it should get expanded or collapsed..
    how to do this one?

  • v-xiaochen-msft Profile Picture
    Microsoft Employee on at

    Hi @Jupyter123 ,

     

    You can add two buttons with the same ‘OnSelect’ and ‘Visible’ as icon.

     

    I made a sample for you.

     

    Add two button to the gallery.

    vxiaochenmsft_0-1669100923942.png

     

     

    The button 'collaspebutton' and the icon 'collaspe' use the same formula.

    Visible = expandCollapse && ThisItem.IsSelected

    OnSelect = UpdateContext({expandCollapse:false})

    vxiaochenmsft_1-1669100923947.png

     

    vxiaochenmsft_2-1669100923950.png

     

     

    The button 'expandbutton' and the icon 'expand' use the same formula.

    Visible = Not(expandCollapse && ThisItem.IsSelected)

    OnSelect = UpdateContext({expandCollapse:true})

    vxiaochenmsft_3-1669100923952.png

     

    vxiaochenmsft_4-1669100923956.png

     

    Best Regards,

    Wearsky

  • Jupyter123 Profile Picture
    403 on at

    @v-xiaochen-msft why do i need 2 buttons? one button is parent of other buttons

    In button, text property, i am having ThisItem.Title and in text label I am having ThisItem.Description.

    So the number of 'title' that i am having in sharepoint will create that many number of buttons . So one button is the parent of other buttons. In this case, how to do this?

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

Season of Sharing Community Challenge Winners!

Congratulations to our community stars!

Kudos to our 2025 Community Spotlight Honorees

Expanding mentorship, skilling, and AI innovation

Leaderboard > Power Apps

#1
11manish Profile Picture

11manish 405 Super User 2026 Season 2

#2
Mohsin Ali Profile Picture

Mohsin Ali 368

#3
WarrenBelz Profile Picture

WarrenBelz 244 Most Valuable Professional

Last 30 days Overall leaderboard