cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
anmdf
Level: Powered On

Making the "Select All" button work for only the filtered items, and clearing the filter

Hello,

 

Good day!

 

I've got a gallery that is set-up like an editable table, with data from a Sharepoint list. I've set up checkboxes for each record so it would be easy to submit changes to multiple items. I've also put a 'Select All' checkbox, and the expression for each of the record checkboxes is  

If(SelectAllCheckbox.Value = true, true, false)

 

I've also set-up a dropdown box for filtering, with items from a column in the gallery. The data for this column varies every now and then, but has common values for each record. Formula is

Dropdown:
Distinct(DataSource, Field1)

Gallery:
Filter(DataSource, Field1 = Dropdown.SelectedText.Value)

Here's how my screen looks like, filtered:

2019-07-03_15-38-47.png

 

My questions are:

1. How do I make the 'Select All' checkbox apply only to the filtered data?

2. How do I make a button or something that would clear the filtered data to show all of the records in the gallery?

 

Thank you!!! Smiley Happy 

1 ACCEPTED SOLUTION

Accepted Solutions
Community Support Team
Community Support Team

Re: Making the "Select All" button work for only the filtered items, and clearing the filter

Hi @anmdf ,

For your first question, could your please share a bit more about it? Do you want the "Select All" Checkbox only works for the filtered items when you want to submit multiple items changes to your SP List?

If you want the "Select All" Checkbox only works for the filtered items when you want to submit multiple items changes to your SP List, I think the Gallery.AllItems formula could achieve your needs. The Gallery.AllItems formula only return current existed items within your Gallery, so if you filter your Gallery items based on the Dropdown box, the Gallery.AllItems formula would return the filtered records. When you check "Select All", only the filtered items in your Gallery would be checked.

When you submit multiple changes to your SP List, please using the following formula:

ForAll(
          RenameColumns(Gallery1.AllItems, "ID", "ID1"),
          Patch(
                    'YourSPList',
                     LookUp('YourSPList', ID = ID1),
                     {
                          Column1: TextInput1.Text,
                          Column2: TextInput2.Text,
                          ...
                     }
          )
)

Note: The TextInput1, TextInput2, ... represents the controls within your Gallery.

More details about ForAll function and Patch fucntion, please check the following article:

ForAll function, Patch function

 

For your second question, have you set Blank as Default value within your filter Dropdown box? If you want to remove the filter condition when you press a button, I have made a test on my side, please take a try with the following workaround:

Set the OnStart property of the App control to following:

ClearCollect(
                   FilterCollection,
                   {Result: Blank()},
                   Distinct(DataSource, Field1)
)

Then set the Items property of the filter Dropdown box (Dropdown) to following:

FilterCollection                                 /** <-- The default value for this filter Dropdown box would be Blank /

Then add a Button (called "Reset Data") within your app, set the OnSelect property to following:

Reset(Dropdown)                           /* <-- Reset filter Dropdown box */

Set the Items proprety of the Gallery to following:

If(
IsBlank(Dropdown.SelectedText.Value),
DataSource,
Filter(DataSource, Field1 = Dropdown.SelectedText.Value)
)

Please consider take a try with above solution, then re-load your your app (to fire the OnStart property of the App control), check if the issue is solved.

 

Best regards,

Community Support Team _ Kris Dai
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
2 REPLIES 2
Super User
Super User

Re: Making the "Select All" button work for only the filtered items, and clearing the filter

Hi @anmdf 

I'n not sure that I can answer all the questions but I would use UpdateContext() to create a variable and use that variable as the Items property of the gallery.  To unfilter the gallery, use

UpdateContext({var: DataSource})

in the OnVisible property of the Screen and as the OnSelect property of the Refresh button. You could then put

 UpdateContext({var:Filter(DataSource, Field1 = Dropdown.SelectedText.Value)})

in the OnChange property of the Dropdown control. 

In the SelectAll button you can simplify your formula to 

SelectAllCheckbox.Value 

 Since it reduces to either true or false without the If().  I believe that you can use the Update() function and the  Gallery.AllItems property as well to Patch the items in the gallery.

 

Community Support Team
Community Support Team

Re: Making the "Select All" button work for only the filtered items, and clearing the filter

Hi @anmdf ,

For your first question, could your please share a bit more about it? Do you want the "Select All" Checkbox only works for the filtered items when you want to submit multiple items changes to your SP List?

If you want the "Select All" Checkbox only works for the filtered items when you want to submit multiple items changes to your SP List, I think the Gallery.AllItems formula could achieve your needs. The Gallery.AllItems formula only return current existed items within your Gallery, so if you filter your Gallery items based on the Dropdown box, the Gallery.AllItems formula would return the filtered records. When you check "Select All", only the filtered items in your Gallery would be checked.

When you submit multiple changes to your SP List, please using the following formula:

ForAll(
          RenameColumns(Gallery1.AllItems, "ID", "ID1"),
          Patch(
                    'YourSPList',
                     LookUp('YourSPList', ID = ID1),
                     {
                          Column1: TextInput1.Text,
                          Column2: TextInput2.Text,
                          ...
                     }
          )
)

Note: The TextInput1, TextInput2, ... represents the controls within your Gallery.

More details about ForAll function and Patch fucntion, please check the following article:

ForAll function, Patch function

 

For your second question, have you set Blank as Default value within your filter Dropdown box? If you want to remove the filter condition when you press a button, I have made a test on my side, please take a try with the following workaround:

Set the OnStart property of the App control to following:

ClearCollect(
                   FilterCollection,
                   {Result: Blank()},
                   Distinct(DataSource, Field1)
)

Then set the Items property of the filter Dropdown box (Dropdown) to following:

FilterCollection                                 /** <-- The default value for this filter Dropdown box would be Blank /

Then add a Button (called "Reset Data") within your app, set the OnSelect property to following:

Reset(Dropdown)                           /* <-- Reset filter Dropdown box */

Set the Items proprety of the Gallery to following:

If(
IsBlank(Dropdown.SelectedText.Value),
DataSource,
Filter(DataSource, Field1 = Dropdown.SelectedText.Value)
)

Please consider take a try with above solution, then re-load your your app (to fire the OnStart property of the App control), check if the issue is solved.

 

Best regards,

Community Support Team _ Kris Dai
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Helpful resources

Announcements
firstImage

Watch Sessions On Demand!

Continue your learning in our online communities.

Top Community Contributors for July 2019

Top Community Contributors for July 2019

Let's thank our top community contributors

Power Platform 2019 release wave 2 plan

Power Platform 2019 release wave 2 plan

Features releasing from October 2019 through March 2020

FirstImage

Power Platform World Tour

Coming to a city near you

thirdimage

PowerApps Community User Group Member Badge

Fill out a quick form to claim your user group badge now!

FourthImage

Join PowerApps User Group!!

Connect, share, and learn with your peers year-round

FifthImage

Dynamics 365 and Power Platform April 2019 Release notes

Features releasing from April 2019 through September 2019!

Users Online
Currently online: 206 members 4,451 guests
Please welcome our newest community members: