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

I don't know how to have a Default selected item in Gallery

I am creating a type of quiz app and I have a Gallery that will auto-populate its contents based on what is selected from the other Gallery.

 

Whenever I select an item from the auto-populated Gallery, I would store the selected item in a Collection:

Collect(selectedItem, Gallery1.Selected);

 

What I am trying to achieve is:

1. Select an item from MainGallery (Gallery1's items change)
2. Select an item from Gallery1 (selected item gets saved to the collection)

3. Select a different item from the MainGallery and go back to the item selected in the previous step

4. Gallery1 has the selected item in the Step 2 preselected

7 REPLIES 7
Highlighted
Solution Supplier
Solution Supplier

Re: I don't know how to have a Default selected item in Gallery

Hi @thebrownfox ,

 

On the Item() Property of the Gallery:

 

If(!IsBlank(selectedItem),
    selectedItem,
    OriginalItem
)

----------------------------------------------------------------------------
Thanks,
K-A-R-L


If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
If you thought this post was helpful, please give it a Thumbs Up.

Highlighted
Frequent Visitor

Re: I don't know how to have a Default selected item in Gallery

Hi @K-A-R-L, This doesn't seem to work.

Highlighted
Solution Supplier
Solution Supplier

Re: I don't know how to have a Default selected item in Gallery

Hi @thebrownfox ,

 

I'm not sure I understand what you're trying to achieve.
I'll assume both galleries are on one screen:

 

What you are trying to achieve:

1. When you Select an item from MainGallery  > Gallery1's item changes
2. When selecting an item from Gallery1 > Selected Item saved to collection //1 Item added in Collection

3. Selecting another item from the MainGallery and go back to the item selected in the previous step //what do you mean by "go back to the item selected in previous step"? Like because you selected another item in there will be 2 Items in the collection now?

4. Gallery1 has the selected item in the Step 2 preselected // Do you want to populate gallery1 with:

  1. Items based on what is selectedon MainGallery
  2. Collected Items "selectedItem"

 

I might help you better if you can provide screenshots or codes.

Apologies.

Highlighted
Community Support
Community Support

Re: I don't know how to have a Default selected item in Gallery

Hi @thebrownfox ,

Do you want to set a default selected item within your Gallery1 based on the selectedItem collection?

 

Based on the issue that you mentioned, I have made a test on my side, please take a try with the following workaround:

set the OnSelect property of the Gallery1 to following:

ClearCollect(selectedItem, Gallery1.Selected)          /* <-- Please use ClearCollect rather than Collect */

Set the Default property of the Gallery1 to following:

If(!IsEmpty(selectedItem),First(selectedItem))

Set the TemplateFill proeprty of the Gallery1 to following:

If(ThisItem.IsSelected, RGBA(255, 228, 196, 1), RGBA(0, 0, 0, 0))   /* <-- Highlight the selected item in your Gallery1 */

Please consider take a try with above solution, then 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.
Highlighted
Frequent Visitor

Re: I don't know how to have a Default selected item in Gallery

Hi,

The question list is the MenuGallery and Gallery1 would have the choices. Gallery1 is filtered based on what is selected in MenuGallery. When I choose an item from Gallery1, I store the item selected. If I leave Question 1 and go back to it, I want the selected item to be preselected. Basically, showing the user the option he selected (if there is) when going back and forth to different questions.

 

Screen Shot 2019-07-18 at 10.16.02 AM.png

Highlighted
Community Support
Community Support

Re: I don't know how to have a Default selected item in Gallery

Hi @thebrownfox ,

Do you want to set the previous selected Gallery1 Item as Default item when you go back to select the Question1 again?

 

Based on the needs that you mentioned, I have made a test on my side, please take a try with the following workaround:

Set the OnSelect property of the Gallery1 to following:

If(
IsBlank(LookUp(TempCollection, QuestionName = MainGallery.Selected.QuestionColumn)),
Collect(
TempCollection,
{
QuestionName: MainGallery.Selected.QuestionColumn, /* <-- QuestionColumn represents the field in your MainGallery to store the Question value -- Question1, Question2, Question3, ... etc*/
selectedItem: Gallery1.Selected
}
)
)

Set the Default property of the Gallery1 to following:

If(
!IsBlank(LookUp(TempCollection, QuestionName = MainGallery.Selected.QuestionColumn, selectedItem)),
LookUp(TempCollection, QuestionName = MainGallery.Selected.QuestionColumn, selectedItem)
)

Set the TemplateFill proeprty of the Gallery1 to following:

If(ThisItem.IsSelected, RGBA(255, 228, 196, 1), RGBA(0, 0, 0, 0))   /* <-- Highlight the selected item in your Gallery1 */ 

 

Please consider take a try with above solution, 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.
Highlighted
Frequent Visitor

Re: I don't know how to have a Default selected item in Gallery

Hi @v-xida-msft 

I tried the solution above but whenever I go to the 2nd question, it shows me the selected option from the 1st question. Whenever I change the answer too, it disappears and jumps back to the first option.

Helpful resources

Announcements
Check this Out

Helpful information

Featuring samples like Return to the Workplace and Emergency Response Applications

August 2020 Community Challenge: Can You Solve These?

August 2020 Community Challenge: Can You Solve These?

We're excited to announce our first cross-community 'Can You Solve These?' challenge!

secondImage

Return to Workplace

Reopen responsibly, monitor intelligently, and protect continuously with solutions for a safer work environment.

secondImage

Super Users Coming in August

We are excited for the next Super User season.

secondImage

Power Platform 2020 release wave 2 plan

Features releasing from October 2020 through March 2021

Top Solution Authors
Top Kudoed Authors
Users online (4,487)