cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
Super User
Super User

Nested Gallery (Gallery within a gallery) - Highlight the selected item in the sub-gallery

I have a Gallery (OrderHeader) that contains a subGallery (OrderDetail). I'm using a GroupBy to populate the galleries:

GroupBy(Filter('[Order].[OrderDetail]',OrderDetailTimeInt >= varTodayInt)  ,"OrderHeaderID","GrpOrderByHeader")

What I want to do, is to highlight the selected item in the OrderDetails sub-gallery, so I set the Fill to:

If(ThisItem.OrderDetailID = GalOrderDetail.Selected.OrderDetailID, LightBlue, RGBA(0, 0, 0, 0))

But when I do this every sub-gallery shows one highlighted entry!

 

I have pasted a screen shot below - the numbers on the far right are OrderDetailID which is unique.

 

How can I get just the selected sub-gallery entry to highlight? This is on a tablet app where a form will appear on the far right to allow editing of the selected Order Detail, so it is important that it is clear which record is being modified.

 

 

 Sketch.png

1 ACCEPTED SOLUTION

Accepted Solutions
Meneghino
Level 10

Re: Nested Gallery (Gallery within a gallery) - Highlight the selected item in the sub-gallery

Hi, I am on mobile so can’t write much. The performant eay is that add back the header id in the items of the sub gallery with the AddColumns function.
14 REPLIES 14
Community Support Team
Community Support Team

Re: Nested Gallery (Gallery within a gallery) - Highlight the selected item in the sub-gallery

Hi @PaulD1,

 

Which part is the gallery and which part is the subgallery? Did you mean that the gallery is filled with blue color too? Could you describe your issue more clearly?

 

Regards,

Mona

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

Re: Nested Gallery (Gallery within a gallery) - Highlight the selected item in the sub-gallery

Hi @v-monli-msft

 

So in the image, the bold text (customer number and order time) is in the main Gallery. All the other lines (menu items) are in the sub-Gallery. I have added to the sub-gallery the OrderDetailID in the image (normally this is not displayed).

 

The OrderDetailID is unique for every row.

 

In the Fill property of the MenuItem label (in the sub-gallery) I have a formula that sets the color to blue if the OrderID for the record matches the OrderID that is currently selected in the sub-gallery.

If(ThisItem.OrderDetailID = GalOrderDetail.Selected.OrderDetailID, LightBlue, RGBA(0, 0, 0, 0))

As you can see from the image, every sub-gallery has one blue item. When you first run the app, this is the first item in each sub-gallery.

 

If I put in a label and set the Text property to GalOrderDetail.Selected.OrderDetailID, it correctly shows the ID of the sub-gallery item I click on.

 

This really looks like a bug to me. In the image, OrderID 78 is the selected item, so why are OrderIDs 82, 85 and 86 blue?

 

There is a sort-of workaround which is to set the template fill of the selected main gallery to (say) blue and non-selected to green. Then set the selected sub-gallery item to green (and leave non-selected as transparent). This way, although every sub-gallery shows a highlighted item, that item has a green background against a green background so is not visible... but it is quite ugly!

Super User
Super User

Re: Nested Gallery (Gallery within a gallery) - Highlight the selected item in the sub-gallery

Hi @v-monli-msft

 

In the image posted, the bold items (Customer and Order Time) are part of the main gallery. There is then a sub-gallery which contains the quantities and the menu-items ordered. I have also included the OrderDetailID in the sub-gallery for the purposes of illustration, i.e. to show that every row has a unique ID.

 

I want only the selected sub-gallery row to be highlighted, but what happens is that every instance of the sub-gallery shows one selected row (even though I have not clicked into those sub-galleries). In the image given, ID 78 has been selected in the first sub-gallery and is correctly shaded blue. But IDs 82, 85 and 86 (in the next three sub-galleries) are also shaded.

 

If I add a label and set the text property to GalOrderDetail.Selected.OrderDetailID it correctly shows the OrderDetailID of the most recently clicked sub-gallery row.

 

Am I missing something or should I report this as a bug?

Meneghino
Level 10

Re: Nested Gallery (Gallery within a gallery) - Highlight the selected item in the sub-gallery

Hi @PaulD1

 

PowerApps is behaving correctly, you need to add the condition that the OrderHeader item is also selected in order to highlight.

Something like this for OrderDetails.TemplateFill...

 

If(ThisItem.OrderHeaderID = GalleryOrderHeader.Selected.OrderHeaderID && ThisItem.OrderDetailID = GalOrderDetail.Selected.OrderDetailID, LightBlue, RGBA(0, 0, 0, 0))

Please let me know if this works or needs adjusting.  It definitely should work.

Super User
Super User

Re: Nested Gallery (Gallery within a gallery) - Highlight the selected item in the sub-gallery

Thanks @Meneghino

 

In the sub-gallery, I cannot refer to ThisItem.OrderHeaderID. I'm Grouping by OrderHeaderID so that field does not appear in the 'sub-record'.

 

To get around that, I have tried using a lookup so I can retrieve the OrderHeaderID for the selected OrderDetailID as below:

 

If(ThisItem.OrderDetailID = GalOrderDetail.Selected.OrderDetailID, If(LookUp('[Order].[OrderDetail]',OrderDetailID = ThisItem.OrderDetailID,OrderHeaderID) = GalOrderHeader.Selected.OrderHeaderID, LightBlue, RGBA(0, 0, 0, 0)),RGBA(0, 0, 0, 0))

This works, but performance is horrible. Between clicking on an item and the highlight appearing can take anywhere from 6 seconds to 20 seconds. Without a lookup, clicking on an item and it being highlighted is pretty much instant.

 

Is there some neater way I can retrieve the OrderHeaderID related to the current 'sub-record' without resorting to a lookup? 

 

Thanks

Paul

Meneghino
Level 10

Re: Nested Gallery (Gallery within a gallery) - Highlight the selected item in the sub-gallery

Hi, I am on mobile so can’t write much. The performant eay is that add back the header id in the items of the sub gallery with the AddColumns function.
Super User
Super User

Re: Nested Gallery (Gallery within a gallery) - Highlight the selected item in the sub-gallery

Thanks @Meneghino 

 

I have it working now - details below for the benefit of anyone stumbling across this thread. I do have an issue in that the comparison in the LookUp element of the Subgallery Items formula is not delegable - I'll post a question about that separately.

 

 

My main gallery's item is now set as:

SortByColumns(GroupBy(Filter('[Order].[OrderDetail]',OrderDetailTimeInt >= (varTodayInt-1)  ,"OrderHeaderID","GrpOrderByHeader"),"OrderHeaderID",Descending)

My Subgallery Item is:

AddColumns(GrpOrderByHeader, "MyOrderHeaderID", LookUp('[Order].[OrderDetail]',GrpOrderByHeader[@OrderDetailID] = OrderDetailID, OrderHeaderID))

And my Fill property for the labels in the subgallery is:

If(ThisItem.OrderDetailID = GalOrderDetail.Selected.OrderDetailID && ThisItem.MyOrderHeaderID = GalOrderHeader.Selected.OrderHeaderID, LightGreen, RGBA(0, 0, 0, 0))

I had a form which has as its Item property GalOrderDetail.Selected - this no longer works, instead, I have had to change it to:

First( Filter('[Order].[OrderDetail]', OrderDetailID = GalOrderDetail.Selected.OrderDetailID))
Meneghino
Level 10

Re: Nested Gallery (Gallery within a gallery) - Highlight the selected item in the sub-gallery

I think ypu do not need the lookup, it is inefficient.
Try something like this for the Items of the subgallery:
AddColumns(GrpOrderByHeader, "MyOrderHeaderID", ThsiItem.OrderHeaderID)
Super User
Super User

Re: Nested Gallery (Gallery within a gallery) - Highlight the selected item in the sub-gallery

Awesome! That is much simpler and more efficient!

Helpful resources

Announcements
firstImage

Watch Sessions On Demand!

Continue your learning in our online communities.

SecondImage

Follow PowerApps on Twitter

Stay Up-to-Date by following PowerApps on Twitter

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: 157 members 4,146 guests
Please welcome our newest community members: