cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
bolin-stratus
Level: Powered On

Render an Icon in Gallery Based on a Text Field

I have a gallery with a SharePoint List as its data source.  I am displaying three items and I'd like to add an icon image based on the text of a 4th item. So if the text of the 4th item from the SP list is "ABC", then render icon_abc.png. If "DEF", then render icon_def.png and so forth.  I'm not sure how to add a 4th item without it being visible. Any recommendations are appreciated.


add icons to gallery.PNG

1 ACCEPTED SOLUTION

Accepted Solutions
shailendra74
Level 8

Re: Render an Icon in Gallery Based on a Text Field

Hi @bolin-stratus 

 

When you attach a datasource to items property, all fields from the datasource can be accessed. And it is not necessary to add a control in the gallery to display the same. So in your case, suppose, the items property has splist1 as datasource, you can access those fields and assign to default/text value of inputtext or label like

 

splist1.Field1

splist1.Field2

splist1.Field3

splist1.Field4

 

So based on the Field4 you can set the Icon property of the Icon as 

 

If( StartsWith(ThisItem.Field4, "Con"),Icon.Add, Icon.Cancel)

Thanks.

3 REPLIES 3
shailendra74
Level 8

Re: Render an Icon in Gallery Based on a Text Field

Hi @bolin-stratus 

 

When you attach a datasource to items property, all fields from the datasource can be accessed. And it is not necessary to add a control in the gallery to display the same. So in your case, suppose, the items property has splist1 as datasource, you can access those fields and assign to default/text value of inputtext or label like

 

splist1.Field1

splist1.Field2

splist1.Field3

splist1.Field4

 

So based on the Field4 you can set the Icon property of the Icon as 

 

If( StartsWith(ThisItem.Field4, "Con"),Icon.Add, Icon.Cancel)

Thanks.

shailendra74
Level 8

Re: Render an Icon in Gallery Based on a Text Field

Hi @bolin-stratus 

 

In case of images set the Image property of an image as

 

If( StartsWith(ThisItem.Field4, "Con") ,abc, def)

abc, def are the images loaded in media files of the app.

 

Thanks

bolin-stratus
Level: Powered On

Re: Render an Icon in Gallery Based on a Text Field

Thank you @shailendra74  for the solution!

Helpful resources

Announcements
firstImage

Watch Sessions On Demand!

Continue your learning in our online communities.

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: 173 members 5,344 guests
Please welcome our newest community members: