Forum Discussion

eis33's avatar
eis33
Copper Contributor
Dec 11, 2024

Lookup Column content disappears with conditional formatting

Hi all,

SharePoint and it pointless limitations (or bugs) drive me crazy again...

I have a list, that is used by different people. As it´s still not possible to color headers or similar, I got used to insert lines left or right of a column via conditional formatting. With such, I create "blocks" of columns for each user. Better that nothing... But now comes the kicker. 

It worked fine so far, but now with a lookup column, the content just disappears. 

This is my list without the border, numbers visible to the left.

Now with formatting applied to the left lookup column, the content is just gone.

I start with "no style" at formatting, as I only want to have the border. The teaser clearly shows, that text should be visible:

 

The json code has some "hidden" attributes in there, but no matter what I change, the content does not reappear.

 

{

"$schema": "https://developer.microsoft.com/json-schemas/sp/v2/column-formatting.schema.json",

"elmType": "div",

"style": {

"box-sizing": "border-box",

"padding": "0 2px",

"overflow": "hidden",

"text-overflow": "ellipsis"

},

"attributes": {

"class": "sp-field-borderRightBold sp-field-borderRightSolid sp-field-fontSizeMedium"

},

"children": [

{

"elmType": "span",

"style": {

"overflow": "hidden",

"text-overflow": "ellipsis",

"padding": "0 3px"

},

"txtContent": "[$PA_x0020_Nr_x002e__x003a__x0020_.lookupValue]",

"attributes": {

"class": "sp-field-fontSizeMedium"

}

}

]

}

Please help... How do I get the border AND my content?

Thanks!

 

2 Replies

  • michalkornet's avatar
    michalkornet
    Iron Contributor

    Hi eis33  , I checked the case again today, and it looks like the issue has been resolved, so your code should work this time

  • michalkornet's avatar
    michalkornet
    Iron Contributor

    Hi eis33  , 

    I am not sure what happened, but I can see that even when the lookup field is set to a single value, it is treated as multi-valued in the formatting.

    I edited your code, and it is now working in my case.

    {
      "$schema": "https://developer.microsoft.com/json-schemas/sp/v2/column-formatting.schema.json",
      "debugMode": true,
      "elmType": "div",
      "style": {
        "box-sizing": "border-box",
        "padding": "0 2px",
        "overflow": "hidden",
        "text-overflow": "ellipsis"
      },
      "attributes": {
        "class": "sp-field-borderRightBold sp-field-borderRightSolid sp-field-fontSizeMedium"
      },
      "children": [
        {
          "forEach": "itemIterator in @currentField",
          "elmType": "div",
          "txtContent": "[$itemIterator.lookupValue]",
          "style": {
            "padding-bottom": "1px"
          }
        }
      ]
    }

     

Resources