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 / Clear Gallery on Click...
Power Apps
Answered

Clear Gallery on Click on Button

(1) ShareShare
ReportReport
Posted on by 652
Hello,
 
I've 2 buttons i.e. Receipt Date and Status. The OnSelect expressions are set as below:
For Receipt Date:
If(
    locFilterBlankReceiptDate,
    UpdateContext({locFilterBlankReceiptDate: false}),
    UpdateContext({locFilterBlankReceiptDate: true})
);
For Status:
If(
    locFilterStatusInProgress,
    UpdateContext({locFilterStatusInProgress: false}),
    UpdateContext({locFilterStatusInProgress: true})
);
An the Items property for Gallery is set to below:
SortByColumns (
    Filter (
        'SharePoinListName',
        Or(
            !locFilterBlankReceiptDate,
            'Receipt Date' = Blank()
        ),
        Or(
            !locFilterStatusInProgress,
            Status = "In Progress"
        )
    ),
    "Modified",
    SortOrder.Descending
)
In need to have 1 more button to Clear the entire gallery.
 
Please advise how can this be done?
Categories:
I have the same question (0)
  • Suggested answer
    WarrenBelz Profile Picture
    153,117 Most Valuable Professional on at
    Firstly, you can shorten the top Variables like this
    UpdateContext({locFilterBlankReceiptDate: !locFilterBlankReceiptDate})
    If you want to clear the entire gallery (show nothing) set this on a button 
     UpdateContext({varClear: true})
    then the Items of the Gallery
    SortByColumns(
       Filter(
          'SharePoinListName
          !varClear,
          Or(
             !locFilterBlankReceiptDate,
             'Receipt Date' = Blank()
          ),
          Or(
             !locFilterStatusInProgress,
             Status = "In Progress"
          )
       ),
       "Modified",
       SortOrder.Descending
    )
    Also at Screen OnVisible and anywhere else you need to reset this
    UpdateContext({varClear: false})
     
    Please click Does this answer your question 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 a Like.
    MVP (Business Applications)    Visit my blog Practical Power Apps    LinkedIn    Buy me a coffee
  • Prem4253 Profile Picture
    652 on at
     
    Thanks! for providing the logic.
     
    But this does not seems working as expected. On Click of clear button, the gallery does not shows any items (is returning blank gallery)
     
    And after clicking the Clear button, when clicked on Receipt Date and Status buttons, this does not shows any records in the gallery.
     
    Also how can we add a Search feature within the Gallery. I have a text input added (TextInput1) for searching within the gallery records.
     
    Appreciate if you can advise with further help.
     
    Thanks! as always for your help.
  • WarrenBelz Profile Picture
    153,117 Most Valuable Professional on at
    That is what I thought you meant by In need to have 1 more button to Clear the entire gallery - what result do you want if not what I supplied ?
    You can add a Search as below (I have omitted the Variable for now)
    With(
       {
          _Data:
          SortByColumns(
             Filter(
                'SharePoinListName
                Or(
                   !locFilterBlankReceiptDate,
                   'Receipt Date' = Blank()
                ),
                Or(
                   !locFilterStatusInProgress,
                   Status = "In Progress"
                )
             ),
             "Modified",
             SortOrder.Descending 
          )
       },
       Search(
          _Data,
          TextInput1.Text,
          YourFieldToSearch
       )
    )
     
    Please click Does this answer your question 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 a Like.
    MVP (Business Applications)    Visit my blog Practical Power Apps    LinkedIn    Buy me a coffee
  • Prem4253 Profile Picture
    652 on at
     
    Thank you once again for your quick response. I'm able to Filter and Search the gallery using the last logic provided.
     
    Below is the screen shot of my App:
     
    Count that we see in above image, are the 5 buttons, which we're using to filter the gallery
     
    For instance when I click Status button, Gallery filters with 6 records.
     
    Now the gallery is filtered with 6 records, so on click of "Clear Gallery" button, I need to reset the gallery to show all records ( i.e. all 13 records)
     
    Similarly when I click "Receipt Date" button, gallery is filtered with 5 records. Now on click of "Clear Gallery" button, reset the gallery to show all records ( i.e. all 13 records)
     
    My Gallery is named as galInspection.
  • Verified answer
    WarrenBelz Profile Picture
    153,117 Most Valuable Professional on at
    You just need to set all the Variables to false on one button
    UpdateContext(
       {   
          locFilterBlankReceiptDate: false,
          locFilterStatusInProgress: false,
          . . . . . .
       }
    )
     
    Please click Does this answer your question 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 a Like.
    MVP (Business Applications)    Visit my blog Practical Power Apps    LinkedIn    Buy me a coffee
  • Prem4253 Profile Picture
    652 on at
     
    You are always there to provide solutions to most of the requirements, which are fulfilled.
     
    Thank you once again for providing the solution on Filtering and Clearing the Gallery.
     
    You Solution helped. Much APPRCIATED.
     
    Thanks,

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 765 Most Valuable Professional

#2
Michael E. Gernaey Profile Picture

Michael E. Gernaey 343 Super User 2025 Season 2

#3
Power Platform 1919 Profile Picture

Power Platform 1919 272

Last 30 days Overall leaderboard