Forum Discussion

jinthakur's avatar
jinthakur
Copper Contributor
Feb 19, 2020

SharePoint 2019 Column Formatting On Premise doesn't work when you add it on a Page with List Web P

SharePoint 2019 Column Formatting On Premise doesn't work when you add it on

a Page with List Web Part

 How to test 

Try this on SharePoint online and On premise

Do column formatting with this json

Then  add a page  with communication template 

Add list select the view 

check the conditional formatting is gone  on On Prem 

 check the conditional formatting is working on On Office 365

Json used  is 

{
 "$schema": "https://developer.microsoft.com/json-schemas/sp/v2/column-formatting.schema.json",
    "debugMode": true,
    "elmType": "div",
    "txtContent": "@currentField",
    "style": {
                "background-color": {
                                        "operator": "?",
                                        "operands": [
                                        {
                                            "operator": "==",
                                            "operands": [
                                                "[$ColorCoded]",
                                                "Red"
                                            ]
                                        },
                                        "red",
                                        {
                                            "operator": "?",
                                            "operands": [
                                            {
                                                "operator": "==",
                                                "operands": [
                                                    "[$ColorCoded]",
                                                    "Blue"
                                                ]
                                            },
                                            "aqua",
                                            {
                                            "operator": "?",
                                            "operands": [
                                            {
                                                "operator": "==",
                                                "operands": [
                                                    "[$ColorCoded]",
                                                    "Green"
                                                ]
                                            },
                                            "Green",
                                            "silver"
                                        ]
                                    }
                                        ]
                                    }   

                                ]
                            },
                "color": "black",
                "padding-left": "10px"
    }

 }

  • I think this could be related to the fact that the list WebPart in SP 2019 is not the most updated one we have in SPO...so if the version in SP 2019 does not support column formatting, that's why you are not seeing your customizations in that WebPart
  • jinthakur2025's avatar
    jinthakur2025
    Copper Contributor

    There is some difference in JSON format in On-prem and Sharepoint onlinejinthakur

    Excel-style Syntax does not work in the On-prem version.

    Inbox me I can rectify this JSON.

  • Jaywork's avatar
    Jaywork
    Copper Contributor

    jinthakur 
    I'm on premise and need to do colour coding. I'm using your code above as a basis but can't tell which "red" for instance is a style declaration and which is the text in the current field.
    I have a choice column called category will values such as "Business", "Project" 
    Are you able to tell me how to amend your code sample to check for these text values please?

Resources