cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
UB400
Kudo Kingpin
Kudo Kingpin

Pass Gallery.Selected.Item from a start screen to another Gallery and Form on another screen?

In a Survey App.I have a Start screen which is something of a Dashboard. I have two non-related Gallery Controls on this page, one of the Gallery Controls displays a list of questions that need to be responded to. I would like to pass on the QuestionID of the selected Gallery item from the start screen to Screen2, where there is a similar Gallery with the same list of questions and alongside that is the text of the question (I'm not using Forms, I place textboxes and TextInput fields directly on the Screen.

 

How can I show the "pre-selected" item from the StartScreen Gallery on the Screen2 Gallery and the related Text field on Screen 2?

I suppose I can pass the Selected value as a Context Variable with the Navigate function, but then how do I show the same "selected" item in the Gallery in Screen2?

 

Is there a way to "select" a Gallery item based on the value of a variable? 

1 ACCEPTED SOLUTION

Accepted Solutions
Meneghino
Community Champion
Community Champion

Hi @UB400

 

Thanks for clarifying.  What I suggested would work, the problem is that there is the issue I referred to: that the Default property of the gallery may not work with an SP list.  The workaround is to load the items into a collection, please refer back to the issue post.

 

Anyway, in you case you need to set the Default property of Gallery2 to:

Gallery1.Selected

If this does not work then in your navigation icon (or whatever it is you put in the Gallery1 template) the OnSelect property should inlcude something like a ClearCollect(MyQuestions, Gallery1.AllItems) before the Navigate statement.   Then the Gallery2 Items property can be MyQuestions.  Or you can even try Gallery1.AllItems as the Items of Gallery2 directly.

 

Please let me know how you get on.

 

PS I assume that you are navigating to Screen2 by pressing the question on the gallery in screen 1. but if you are not then the above still works.

View solution in original post

5 REPLIES 5
Meneghino
Community Champion
Community Champion

Hi @UB400

 

I am not entirely clear on what you are trying to do, but:

 

1) You can pre-select an item of a gallery by setting the gallery's Default property.  Please note that this property currently has some issues as described here

 

2) There is no need to use a context variable, you can directly refer to the Selected property of any gallery in any screen from any other screen

 

Please let me know if anything requires clarification or you need further help.

@Meneghino thanks for the quick response. Let me see if I can clarify what I'm trying to achieve:

 

On Screen1 I have Gallery1, in Gallery1 I'm displaying two fields "Title" and "DetailTxt", these are populated from a SP list called Questions.

 

If a User selects a Title in Gallery1, I want to take them to Screen2, where there is Gallery2, alongside which there is a TextBox showing the Text value of Gallery2.Selected.Title and another Textbox showing Text value of Gallery2.Selected.DetailTxt

 

When the User arrives on Screen2, I would like them to see the same Selected Item in Gallery2 as the one they had selected in Gallery1 (on Screen1) and also the contents of the the two textboxes to reflect the values of the correctly selected item in Gallery2.

 

As Screen1 is a Dashboard and has other Galleries, I did not want the User to got to a new screen and only see the one question, instead I would like them to see all the questions, so that they do not have to keep going back to Screen1 to select another question.

 

In other words, if I select Question1 on Screen1, when I get to Screen2, i want to be able to answer other Questions instead of having to keep navigating back to Screen1 to select another question.

 

Sorry for the long scenario.

Meneghino
Community Champion
Community Champion

Hi @UB400

 

Thanks for clarifying.  What I suggested would work, the problem is that there is the issue I referred to: that the Default property of the gallery may not work with an SP list.  The workaround is to load the items into a collection, please refer back to the issue post.

 

Anyway, in you case you need to set the Default property of Gallery2 to:

Gallery1.Selected

If this does not work then in your navigation icon (or whatever it is you put in the Gallery1 template) the OnSelect property should inlcude something like a ClearCollect(MyQuestions, Gallery1.AllItems) before the Navigate statement.   Then the Gallery2 Items property can be MyQuestions.  Or you can even try Gallery1.AllItems as the Items of Gallery2 directly.

 

Please let me know how you get on.

 

PS I assume that you are navigating to Screen2 by pressing the question on the gallery in screen 1. but if you are not then the above still works.

@Meneghino Dude you're AWESOME!

 

The last option of using Gallery1.Items as the Items for Gallery2 worked! I did use a Collection as the DataSource for Gallery1, as I did not want to battle with Sharepoint issue that you had mentioned from the other post.

Hi @Meneghino

 

I was able to execute your formula. I have a display screen and edit screen and I'm using tabbed form. If my user changes tab selection in display screen, say Tab 4, when they go to Edit Screen it also selects Tab 4 which is good. My problem though is while on Edit Screen, they can switch tab as well and I could not figure out how can I pass that selection back to display screen. 

 

Lee

Helpful resources

Announcements
Power Apps News & Annoucements carousel

Power Apps News & Announcements

Keep up to date with current events and community announcements in the Power Apps community.

Community Call Conversations

Introducing the Community Calls Conversations

A great place where you can stay up to date with community calls and interact with the speakers.

Power Apps Community Blog Carousel

Power Apps Community Blog

Check out the latest Community Blog from the community!

Top Solution Authors
Top Kudoed Authors
Users online (3,107)