cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
ChrisBrazeau
Helper I
Helper I

How do i keep persistent gallery filters

I have 3 dropdowns on a gallery page, after filtering the worker then selects the item and goes to the edit screen, after completing the forum i have created a submit form button and a back button. When the worker goes back all the filters are reset. 

 

How can I make the filters stay persistent ? Is there a way to create a small checkbox beside each filter that I want to keep ?

 

Here is the code for my filters

 

OnVisible:

ClearCollect(KL1,Filter('KL Traveller', 'Train Set' ="9"));
ClearCollect(KL2,Filter('KL Traveller', 'Train Set' ="10"));
ClearCollect(KL3,Filter('KL Traveller', 'Train Set' ="11"));
ClearCollect(KL4,Filter('KL Traveller', 'Train Set' ="12"));
ClearCollect(KL5,Filter('KL Traveller', 'Train Set' ="13"));
ClearCollect(KL6,Filter('KL Traveller', 'Train Set' ="14"));
ClearCollect(KLall,KL1,KL2,KL3,KL4,KL5,KL6);

ClearCollect(collectvideo, {Result: "All"});
Collect(collectvideo, Distinct(KLall,'Car Number'));
ClearCollect(collectvideomodule, {Result: "All"});
Collect(collectvideomodule, Distinct(KLall, 'Production Percent Complete'.Value));
ClearCollect(collectstation, {Result: "All"});
Collect(collectstation, Distinct(KLall,Station))

 

Items:

If(ddCarNumber.Selected.Result ="All" And ddModule.Selected.Result ="All" And ddStation.Selected.Result ="All", 'KL Traveller',
ddCarNumber.Selected.Result = "All" And ddStation.Selected.Result ="All" And ddModule.Selected.Result <> "All",
Filter('KL Traveller', 'Production Percent Complete'.Value = ddModule.Selected.Result),
ddCarNumber.Selected.Result <> "All" And ddModule.Selected.Result = "All"And ddStation.Selected.Result ="All",
Filter('KL Traveller', 'Car Number' = ddCarNumber.Selected.Result),
ddCarNumber.Selected.Result <> "All" And ddModule.Selected.Result <> "All"And ddStation.Selected.Result ="All",
Filter('KL Traveller', 'Car Number' =ddCarNumber.Selected.Result And 'Production Percent Complete'.Value =ddModule.Selected.Result),
ddCarNumber.Selected.Result <> "All" And ddModule.Selected.Result <> "All"And ddStation.Selected.Result <>"All",
Filter('KL Traveller', 'Car Number' =ddCarNumber.Selected.Result And 'Production Percent Complete'.Value =ddModule.Selected.Result),
ddCarNumber.Selected.Result = "All" And ddModule.Selected.Result = "All"And ddStation.Selected.Result <>"All",
Filter('KL Traveller', Station =ddStation.Selected.Result),
ddCarNumber.Selected.Result <> "All" And ddModule.Selected.Result = "All"And ddStation.Selected.Result <>"All",
Filter('KL Traveller', 'Car Number' =ddCarNumber.Selected.Result And Station =ddStation.Selected.Result),
ddCarNumber.Selected.Result = "All" And ddModule.Selected.Result <> "All"And ddStation.Selected.Result <>"All",
Filter('KL Traveller', 'Production Percent Complete'.Value =ddModule.Selected.Result And Station =ddStation.Selected.Result))

 

I tried using the defualt value of the filter itself as varFilterColumn1 and then setting OnChange to Set(varFilterColumn1, ddCar2.Selected.Value). But all this did was showed the filters for about 10 seconds and then reset it back to default.

 

 

Thanks for the help

 

ChrisCapture.PNG

2 REPLIES 2
Drrickryp
Super User II
Super User II

Hi @ChrisBrazeau 

Without looking at the OnVisible property that creates the collections, I tried to simplify your code for the Items in your gallery, but made no attempt to evaluate whether the filters work.  I am assuming that they do. I would place this code in the OnSuccess property of your form. It will then produce a single global variable called "fltdItems" based on the conditions of your dropdowns.  You would use that the Items property of the gallery. 

 

 

With(
     {ddCN:ddCarNumber.Selected.Result, ddM:ddModule.Selected.Result, ddS:ddStation.Selected.Result, KLT:'KL Traveller'},

  If(
       ddCN = And(
                  "All", ddM = "All", ddS ="All"
               ), Set(fltdItems, KLT),

       ddCN = And(
                  "All" , ddS = "All", ddM <> "All"
               ), Set(fltdItems, Filter(KLT, 'Production Percent Complete'.Value = ddM
                                 )
                  ),

        ddCN <> And(
                    "All", ddM = "All", ddS ="All"
                 ),  Set(fltdItems, Filter(KLT, 'Car Number' = ddCN
                                     )
                     ),

         ddCN <> And(
                      "All", ddM <> "All", ddS ="All"
                  ), Set(fltdItems, Filter(KLT, 'Car Number' = ddCN And 'Production Percent Complete'.Value = ddM
                                     )
                      ),

         ddCN <> And(
                     "All", ddM <> "All", ddS <>"All"
                 ), Set(fltdItems, Filter(KLT, 'Car Number' =ddCN And 'Production Percent Complete'.Value =ddM
                                    )
                     ),

         ddCN = And(
                    "All", ddM = "All", ddS <>"All"
                 ), Set(fltdItems, Filter(KLT, Station = ddS
                                    )
                     ),
   
         ddCN <> And(
                      "All", ddM = "All", ddS <>"All"
                 ), Set(fltdItems, Filter(KLT,'Car Number' = ddCN And Station =ddS
                                   )
                     ),

         ddCN = And(
                    "All", ddM <> "All",  ddS <>"All"
                 ), Set(fltdItems, Filter(KLT, 'Production Percent Complete'.Value =ddM And Station =ddS
                                    )
                     )
   )
)

 

The global variable should persist until the form is resubmitted, creating a new value for the global variable.

 

 

Untitled.png

Thanks for responding. 

 

When adding this to the OnSuccess of my forum it gives me an incompatible error. I attempted it anyways and it is giving me the same behavior as the previous thing i tried. It shows the filters as the correct ones, then it loads and poof back to the default ones!

Helpful resources

Announcements
PA User Group

Welcome to the User Group Public Preview

Check out new user group experience and if you are a leader please create your group

secondImage

Demo Extravaganza is Back!

We are excited to announce that Demo Extravaganza for 2021 has started!

MBAS on Demand

Microsoft Business Applications Summit sessions

On-demand access to all the great content presented by the product teams and community members! #MSBizAppsSummit #CommunityRocks

Power Apps June 2021

June Power Apps Community Call

Don't miss the call this month on June 16th - 8a PDT

Top Solution Authors
Top Kudoed Authors
Users online (68,695)