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 / Reset Gallery but unse...
Power Apps
Suggested Answer

Reset Gallery but unselect item

(2) ShareShare
ReportReport
Posted on by 10

Hi!

I have a display gallery with the following Items property:

With({_items:AddColumns('PSMC Cover Pods',"dname",Name.DisplayName)},

SortByColumns(
Filter(_items,Len(TextInput2.Text)=0 ||
TextInput2.Text in dname
),"dname", SortOrder.Ascending))

 

I have a button with Reset(Gallery1). However when I reset the Gallery it goes back and selects the first record.

 

To solve this, I put {} in the Gallery Default Property. Now it no longer selects the first record when I navigate to the Gallery. However, it also doesn't reset the Gallery any more!

 

How can I solve this?

 

Categories:
I have the same question (0)
  • JohnM86 Profile Picture
    590 on at

     

    To reset the gallery and ensure that it doesn't select the first record when you navigate to the gallery, you can use the following formula for the gallery Items property:

     

    If(IsBlank(TextInput2.Text), {}, With({_items:AddColumns('PSMC Cover Pods',"dname",Name.DisplayName)}, SortByColumns( Filter(_items,TextInput2.Text in dname), "dname", SortOrder.Ascending ) ) )
     

    This formula uses the IsBlank() function to check if the TextInput2 control is blank. If it is, it returns an empty collection {}, which will clear the gallery. If it's not, it will filter and sort the items as before.

    By using this formula, you can still reset the gallery with Reset(Gallery1), and it won't select the first record when you navigate to it.

     

  • Tanners_PP Profile Picture
    10 on at

    Thanks @JohnM86  - however I get an error saying "Expected Table Value".

  • JohnM86 Profile Picture
    590 on at

    Could you try with :

     

    If(IsBlank(TextInput2.Text), {}, With({_items:AddColumns('PSMC Cover Pods',"dname",Name.DisplayName)}, SortByColumns(Filter(_items,TextInput2.Text in dname), "dname", SortOrder.Ascending)).dname)

  • Suggested answer
    CodeAvenue Profile Picture
    104 on at
    Hi @Tanners_PP,
    A no fail solution that has worked for me is to set the gallery default to a variable example varGallery1
    On the OnVisible of the Screen on which you've the gallery, set that the variable to blank, Set(varGallery1,Blank()); 
    Now, you will want to collect the current selected gallery item into the variable  Set(varGallery1,ThisItem); 
    Then finally, anywhere (this can be a button or icon) you want the OnSelect property to clear the gallery selection, Set(varGallery1, {}); 

    Hope this helps anyone looking for this powerful solution! 

    Cheers

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

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Users!

Kudos to our 2025 Community Spotlight Honorees

Congratulations to our 2025 community superstars!

Congratulations to the April Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Apps

#1
Vish WR Profile Picture

Vish WR 1,070

#2
Valantis Profile Picture

Valantis 639

#3
11manish Profile Picture

11manish 608

Last 30 days Overall leaderboard