cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
JulianKirkness
Advocate I
Advocate I

Can you highlight the selected record in a Gallery

It would be really useful (especially in tablet pages) to be able to highligt the selected record in a Gallery control. Is this possible?

1 ACCEPTED SOLUTION

Accepted Solutions
mr-dang
Community Champion
Community Champion

Galleries have two fill properties: Fill and TemplateFill. Fill is the background of the Gallery. TemplateFill can color individual records. In your case, you will need to edit the TemplateFill

 

For Gallery1.TemplateFill:

If(Title=Gallery1.Selected.Title,
RGBA(color that you want selected), 
RGBA(regular color)
)

Change Title to whatever column of yours has unique values. 

Microsoft Employee
@8bitclassroom

View solution in original post

18 REPLIES 18
hpkeong
Community Champion
Community Champion

Hi:

 

Yes, it is possible.

I have shared before and wish to share here again.

 

How to set color by for EVEN and ODD Rows?
(This is what normally we can get easily when making Excel Table)

1. In Excel Table, Include ID in the first column. (for CDM/CDS< you may refer to Title, or any other sequence no.)

In the case of Excel: see 2, 3, 4

2. When Adding Record from Screen 1 and Navigate to Screen 1
Set OnSelect To: Navigate(……………, {Record: Defaults(TableX)})

3. When saving on Screen 2, set
OnSelect: UpdateContext({Record: Patch(TableX, Record, {ID: If(!IsBlank(Record.ID), Record.ID, Text(Max(TableX, ID) + 1)),……..}

4. When navigate back to Screen 1 with Gallery, set the
Gallery Template, Inserted Shape, or Any TextBox or Shape, to set the FILL or Color with:
If(Right(Text(Value(ThisItem.ID)/2, "#.#"), 1) = "5", Color!AliceBlue, Color!Aqua))
Or
If(Mod(Value(ThisItem.ID), 2) = 0, Color!AliceBlue, Color!Aqua))


With this, you can have the Alternate Color as of Excel Table.

NB: It was told that this is not supported in Project Siena and PowerApps, but with ID number created automatically (as of No. 3), this can be accomplished.
In fact, under C# (if not mistaken), it can be done with:
WHERE CAST (Left(Right(IDNUMBER, 2),1) As Int) % 2 = 0 (As provided by friend, easily)

 

Hope this helps.

hpkeong

I don't think this is the same - I am talking about having a Gallery on the left hand side of a tablet screen with details to the right. I would like to highlight the selected row in the gallery (mainly for aesthetic reasons).

Hi

 

Yes, it is possible. Tricks using If as well and OnSelect.

Currently no example to share (as my system is slow here).

THanks.

hpkeong
hpkeong
Community Champion
Community Champion

Hi

 

Spare some free time on Sunday to create a sample and hope it works.

 

Please remember to add an, e,g,:

- Button inside the gallery (to replace the normal Arrow Icon, where the Button fill up the whole gallery row).

- Delete the text "Button"

- Then Button.Fill = If(ThisItem.IsSelected, ColorA, ColorB)

- Make sure the transparency of the color, RGBA( x1, x2, x3, Transprency value) is set to what you wish to ahve.

 

 

 

 Screenshot (40).pngScreenshot (41).png

hpkeong
mr-dang
Community Champion
Community Champion

Galleries have two fill properties: Fill and TemplateFill. Fill is the background of the Gallery. TemplateFill can color individual records. In your case, you will need to edit the TemplateFill

 

For Gallery1.TemplateFill:

If(Title=Gallery1.Selected.Title,
RGBA(color that you want selected), 
RGBA(regular color)
)

Change Title to whatever column of yours has unique values. 

Microsoft Employee
@8bitclassroom

View solution in original post

Thanks @mr-dang just what I was looking for.

amarion
Frequent Visitor

"Title" is a little misleading. i was using the title tag at first. But you did clarify use a unique column.

You can also use the ThisItem.IsSelected property, so you don't need to know about unique values in the data source:

If(
    ThisItem.IsSelected,
    RGBA(color that you want selected),
    RGBA(regular color)
)

Just to clarify, put the following code in the TemplateFill Property of the gallery control

 

      If( ThisItem.IsSelected, RGBA(196, 196, 196, 50%), RGBA(0, 0, 0, 0))

 

This examples fills with gray... 

 

Works great but I have not yet figured out how to select multiple items ( tried holding Shift key and ctrl key - no go ) Seems like you can only select 1 item at at time... maybe you will find a trick to select many items to highlight many rows in a gallery?

 

Helpful resources

Announcements
UG GA Amplification 768x460.png

Launching new user group features

Learn how to create your own user groups today!

Community Connections 768x460.jpg

Community & How To Videos

Check out the new Power Platform Community Connections gallery!

M365 768x460.jpg

Microsoft 365 Collaboration Conference | December 7–9, 2021

Join us, in-person, December 7–9 in Las Vegas, for the largest gathering of the Microsoft community in the world.

Top Solution Authors
Top Kudoed Authors
Users online (2,108)