0

Using JSON formatting, is it possible to hide a column based on another column value.

Example:
View displays columns A, B, C and D
View is limited to one row
If the value in column D equals Yes, don't display column A.

Edit - SP Online modern site is being used.

2 Answers 2

0

If your are not using a modern site, i will advise you to use JSLink

CSharpCorner

1
  • I'll give it a shot and report back. Thx! Dec 3, 2019 at 15:30
0

You could use the below JSON code to format the column A:

{
  "$schema": "https://developer.microsoft.com/json-schemas/sp/v2/column-formatting.schema.json",
  "debugMode": true,
  "elmType": "div",
  "txtContent": "@currentField",
  "style": {
    "display": "=if([$ColumnD]=='Yes','none','')"
  }
}

Test Result:

enter image description here

2
  • close. I'm wanting to hide the column, not just the value. my view is filtered to one row. Dec 6, 2019 at 22:15
  • So you want to hide the column header too. However, we cannot not only hide only one column header using JSON View Formatting. We could use "hideColumnHeader": true to hide column headers, but it would hide all column headers. Please read here for more :docs.microsoft.com/en-us/sharepoint/dev/… Dec 9, 2019 at 8:49

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.