How to show Icon along with Text in SharePoint List multi choice field via Json code in customized column formatting

Gouthami pingali 5 Reputation points
2023-01-17T09:28:43.1433333+00:00

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" } ] }

Microsoft 365 and Office | Development | Other
Microsoft 365 and Office | SharePoint | Development
{count} votes

3 answers

Sort by: Most helpful
  1. Gouthami pingali 5 Reputation points
    2023-01-18T12:20:20.4033333+00:00

    Please don't say its impossible when the possibility is there. I have done it with coloring fail.

    Will you able to help me to show exact color as icon, now as you can see here in the down all icons showing in black here. But , i would like it to display exactly as the icon color as showed in second picture.. Code is attached final.txt ..

    success

    User's image

    1 person found this answer helpful.
    0 comments No comments

  2. AllenXu-MSFT 24,951 Reputation points Moderator
    2023-01-18T02:50:34.62+00:00

    Hi @Gouthami Pingali ,

    As per my test, no, I'm afraid it is impossible for a multiple selection choice column to display like "Icon-Chosenvalue" for multiple values. It only can be achieved in a single selection choice column using JSON. For a multiple selection choice column,

    actually I'm afraid it can only show value-related icons and show description when mouse on-hover. See this demo: SharePoint column formatting - Using UI icons with choice column formats badly in form.


    If the answer is helpful, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".

    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.

    0 comments No comments

  3. Gouthami pingali 5 Reputation points
    2023-01-19T15:59:26.83+00:00

    Please close this thread... Thank you for your response


Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.