cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
wwallace86
Frequent Visitor

How to refresh a collection that is displayed in a gallery when a different dropdown value has been selected

SO I'm having a problem, maybe someone can clue me into how to solve this.

 

I have a collection that is shown in a gallery based upon what is selected with a radio button IF statement selection based upon 2 different selections from a dropdown value that has been selected.

 

My problem is anytime I make the initial dropdown selection, then select my radio button option, I can't change or "Reset" the information shown in the gallery information if I change the dropdown from "Live" to "Dark" and back again. The information displayed in the gallery stays the same.

 

here is the code for the OnChange for the radio button selection so you kind of know what I am working with.

If(Dropdown_partner.Selected.Value = "Live",
UpdateContext({Loadingvar:true});
    Switch(P2PTypeRadio.Selected.Value, "Zone2Zone", 
          UpdateContext( {allSel: Filter(colLocations, ZoneLeader = "Yes" And Live="Yes")} );
          UpdateContext( {formType: "Zone2Zone"}), "New2Zone",
          UpdateContext( {allSel: Filter( colLocations, ZoneLeader = "Yes" || New = "New" && Live="Yes")} );
          UpdateContext( {formType: "New2Zone"}), "Zone2Zone w/New",
          UpdateContext( {allSel: Filter( colLocations, ZoneLeader = "Yes" || New = "New" && Live="Yes")} );
          UpdateContext( {formType: "Zone2Zone w/New"}), "Custom",
          UpdateContext( {formType: "Custom"}), "All", 
          UpdateContext( {allSel: Filter(colLocations,New="New"||New="Normal" && Live="Yes")} );
          UpdateContext( {formType: "All"}) );
             Clear(colComboTrips);
       UpdateContext({Loadingvar:false});)
Or

If(Dropdown_partner.Selected.Value = "Dark",
UpdateContext({Loadingvar:true});
    Switch(P2PTypeRadio.Selected.Value, "Zone2Zone", 
          UpdateContext( {allSel: Filter(colLocations, ZoneLeader = "Yes" && Dark="Yes")} );
          UpdateContext( {formType: "Zone2Zone"}), "New2Zone",
          UpdateContext( {allSel: Filter( colLocations, ZoneLeader = "Yes" || New = "New" && Dark="Yes")} );
          UpdateContext( {formType: "New2Zone"}), "Zone2Zone w/New",
          UpdateContext( {allSel: Filter( colLocations, ZoneLeader = "Yes" || New = "New" && Dark="Yes")} );
          UpdateContext( {formType: "Zone2Zone w/New"}), "Custom",
          UpdateContext( {formType: "Custom"}), "All", 
          UpdateContext( {allSel: Filter(colLocations,New="New"||New="Normal" && Dark="Yes")} );
          UpdateContext( {formType: "All"}) );
             Clear(colComboTrips);
       UpdateContext({Loadingvar:false});)

 

3 REPLIES 3
RandyHayes
Super User III
Super User III

@wwallace86 

We had this thread going last week.  There were some outstanding questions in it and a formula I provided as a solution for you.

Can you provide some answers from that original thread and perhaps we can pick up on this and resolve for you.

 

Really need to move this to the Items property of your Gallery or define the purpose of the variables you have.

_____________________________________________________________________________________
Digging it? - Click on the Thumbs Up. Solved your problem? - Click on Accept as Solution. Others seeking the same answers will be happy you did.
Check out my PowerApps Videos too!

I can't define what the variable "allRes" is because I was re-assigned to this project and the person who developed it to begin with is no longer with the company.

All I want to do is change or "Reset" the collection of information shown in the gallery if I change the dropdown from "Live" to "Dark" or back again. As of now, the collection information displayed in the gallery stays the same if I change the dropdown after the Combo Box "If" statement has been run..

 

Hope this helps.

RandyHayes
Super User III
Super User III

@wwallace86 

Yes, I recall that from the prior post.  The point being, that you would normally want to put this type of formula in the Gallery Items property rather than constantly gathering into a redundant variable as you have now.

 

But I am sensing that moving this in the right direction is not as important as getting the existing to "work" to some degree.

So, with that in mind, you need to change your formula to the following:

UpdateContext({Loadingvar:true});

Switch(Dropdown_partner.Selected.Value,
    "Live",
        Switch(P2PTypeRadio.Selected.Value, 
            "Zone2Zone", UpdateContext({allSel: Filter(colLocations, ZoneLeader = "Yes" And Live="Yes"), formType: "Zone2Zone"}), 
            "New2Zone", UpdateContext({allSel: Filter( colLocations, ZoneLeader = "Yes" || New = "New" && Live="Yes"), formType: "New2Zone"}), 
            "Zone2Zone w/New", UpdateContext( {allSel: Filter( colLocations, ZoneLeader = "Yes" || New = "New" && Live="Yes"), formType: "Zone2Zone w/New"}), 
            "Custom", UpdateContext( {formType: "Custom"}), 
            "All", UpdateContext( {allSel: Filter(colLocations,New="New"||New="Normal" && Live="Yes"), {formType: "All"}) 
        ),
          
    "Dark",
        Switch(P2PTypeRadio.Selected.Value, 
            "Zone2Zone", UpdateContext({allSel: Filter(colLocations, ZoneLeader = "Yes" && Dark="Yes"), formType: "Zone2Zone"}), 
            "New2Zone", UpdateContext({allSel: Filter( colLocations, ZoneLeader = "Yes" || New = "New" && Dark="Yes"), {formType: "New2Zone"}), 
            "Zone2Zone w/New", UpdateContext({allSel: Filter( colLocations, ZoneLeader = "Yes" || New = "New" && Dark="Yes"), formType: "Zone2Zone w/New"}), 
            "Custom", UpdateContext( {formType: "Custom"}), 
            "All", UpdateContext( {allSel: Filter(colLocations,New="New"||New="Normal" && Dark="Yes"), formType: "All"}) 
        )
)

Clear(colComboTrips);
UpdateContext({Loadingvar:false});)

 

_____________________________________________________________________________________
Digging it? - Click on the Thumbs Up. Solved your problem? - Click on Accept as Solution. Others seeking the same answers will be happy you did.
Check out my PowerApps Videos too!

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

PA Community Call

Power Apps Community Call

Next call is happening on April 21st at 8a PST.

MBAS Carousel

Sign up for our May 4th event!

May the fourth be with you, join us online!

secondImage

Experience what’s next for Power Apps

See the latest Power Apps innovations, updates, and demos from the Microsoft Business Applications Launch Event.

Top Solution Authors
Top Kudoed Authors
Users online (76,553)