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

Notifications

Announcements

Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Apps / Reset Gallery but unse...
Power Apps
Unanswered

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

Forum hierarchy changes are complete!

In our never-ending quest to improve we are simplifying the forum hierarchy…

Ajay Kumar Gannamaneni – Community Spotlight

We are honored to recognize Ajay Kumar Gannamaneni as our Community Spotlight for December…

Leaderboard > Power Apps

#1
WarrenBelz Profile Picture

WarrenBelz 717 Most Valuable Professional

#2
Michael E. Gernaey Profile Picture

Michael E. Gernaey 329 Super User 2025 Season 2

#3
Power Platform 1919 Profile Picture

Power Platform 1919 268

Last 30 days Overall leaderboard