1

so basically I have a library of nested folders and a column with a request approval button. I'd like to be able to hide the button for all folders and leave it visible for all files. I've tried a few things, but I'm really new to json and not having much luck.

  "$schema": "https://developer.microsoft.com/json-schemas/sp/column-formatting.schema.json",
  "elmType": "button",
  "customRowAction": {
    "action": "executeFlow",
    "actionParams": "{\"id\": \"\"}"
  },
  "attributes": {
    "class": "ms-fontColor-themePrimary ms-fontColor-themeDarker--hover"
  },
  "style": {
    "border": "none",
    "cursor": "pointer",
    "background-color": "#D5D5D5",
    "color": "#000",
    "padding": "4px 4px 4px 10px",
    "border-radius": "5px"
  },
  "children": [
    {
      "elmType": "span",
      "txtContent": "Request approval"
    }
  ]
}

1 Answer 1

0

There are a couple of ways to do this. The most common is to use the [$File_x0020_Type] column and check when it's blank. A method I tend to prefer, however, is to use the [$ContentType] column and check when it equals Folder.

Your format could have conditional display using an expression like this:

{
  "$schema": "https://developer.microsoft.com/json-schemas/sp/column-formatting.schema.json",
  "elmType": "button",
  "customRowAction": {
    "action": "executeFlow",
    "actionParams": "{\"id\": \"\"}"
  },
  "attributes": {
    "class": "ms-fontColor-themePrimary ms-fontColor-themeDarker--hover"
  },
  "style": {
    "border": "none",
    "cursor": "pointer",
    "background-color": "#D5D5D5",
    "color": "#000",
    "padding": "4px 4px 4px 10px",
    "border-radius": "5px",
    "display": "=if([$ContentType]=='Folder', 'none', 'inherit')"
  },
  "children": [
    {
      "elmType": "span",
      "txtContent": "Request approval"
    }
  ]
}

Your Answer

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

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