Hello,
I am trying to show Icon along with Text in SharePoint List multi choice field column in json formatting. but its not working. when we hover a mouse, it shows a name but we would like to display it like below in column itself along with icon and text in whichever way its possible
Icon-Chosenvalue or Icon(Chosenvalue) or IconChosenValue
I have tried below codes with Fail, it display in single column all values. Appreciate the help.
{ "$schema": "https://developer.microsoft.com/json-schemas/sp/column-formatting.schema.json", "elmType": "div", "attributes": { "class": "sp-field-severity--good" }, "children": [ { "elmType": "span", "attributes": { "iconName": "SharePointLogo" } }, { "elmType": "span", "txtContent": "SharePoint Online" }, { "elmType": "span", "attributes": { "iconName": "WindowsLogo" } }, { "elmType": "span", "txtContent": "Windows" }, { "elmType": "span", "attributes": { "iconName": "Waffle" } }, { "elmType": "span", "txtContent": "Microsoft 365 Apps" } ] }
Also below code by using if condition
{ "$schema": "https://developer.microsoft.com/json-schemas/sp/column-formatting.schema.json", "elmType": "div", "style": { "font-size": "20px" }, "children": [ { "elmType": "span", "style": { "display": "inline-block", "padding": "0 4px" }, "attributes": { "iconName": "=if(@currentField == 'Windows', 'WindowsLogo', if(@currentField == 'SharePoint Online', 'SharePointLogo', if(@currentField == 'Microsoft 365 Apps', 'Waffle', if(@currentField == 'Microsoft Teams', 'TeamsLogo'))))" } }, { "elmType": "span", "txtContent": "@currentField" } ] }