Skip to main content

Notifications

Power Apps - Building Power Apps
Answered

Clear Gallery on Click on Button

(1) ShareShare
ReportReport
Posted on by 271
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?
  • Prem4253 Profile Picture
    Prem4253 271 on at
    Clear Gallery on Click on Button
     
    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,
  • Verified answer
    WarrenBelz Profile Picture
    WarrenBelz 145,434 on at
    Clear Gallery on Click on Button
    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
    Prem4253 271 on at
    Clear Gallery on Click on Button
     
    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.
  • WarrenBelz Profile Picture
    WarrenBelz 145,434 on at
    Clear Gallery on Click on Button
    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
    Prem4253 271 on at
    Clear Gallery on Click on Button
     
    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.
  • Suggested answer
    WarrenBelz Profile Picture
    WarrenBelz 145,434 on at
    Clear Gallery on Click on Button
    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

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

Microsoft Kickstarter Events…

Register for Microsoft Kickstarter Events…

Announcing Our 2025 Season 1 Super Users!

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

Announcing Forum Attachment Improvements!

We're excited to announce that attachments for replies in forums and improved…

Leaderboard

#1
WarrenBelz Profile Picture

WarrenBelz 145,434

#2
RandyHayes Profile Picture

RandyHayes 76,287

#3
Pstork1 Profile Picture

Pstork1 64,722

Leaderboard