首页 > 解决方案 > 如何使 SharePoint 库中的自定义列按钮仅在文件类型为“文件夹”时可见

问题描述

我有一个自定义按钮列(测试)

我想为仅在文件类型 = 文件夹时显示按钮设置条件。下面是我的 Json 代码,但不幸的是它不起作用。

  {
  "$schema": "http://columnformatting.sharepointpnp.com/columnFormattingSchema.json",
  "elmType": "button",
  "customRowAction": 
{
    "action": "executeFlow",
    "actionParams": "{\"id\": \"\"}"


  },
  "style": {
    "border": "none",
    "background-color": "transparent",
    "color": "#0078d7",
    "cursor": "pointer",
"display": "=if(  ([$Type] == 'Folder' ), 'block', 'none')"
  },
  "children": [
    {
      "elmType": "span",
      "attributes": {
        "iconName": "FollowUser"
      },
      "style": {
        "padding-right": "6px"
      }
    },
    {
      "elmType": "span",
      "txtContent": "click to start"
    }
  ]
}

在此处输入图像描述

标签: jsonsharepointoffice365power-automate

解决方案


SharePoint 库中有一个内容类型列,您可以通过判断该列的值来决定是否显示该按钮。

{
  "$schema": "http://columnformatting.sharepointpnp.com/columnFormattingSchema.json",
  "elmType": "button",
  "customRowAction": 
{
    "action": "executeFlow",
    "actionParams": "{\"id\": \"\"}"


  },
  "style": {
    "border": "none",
    "background-color": "transparent",
    "color": "#0078d7",
    "cursor": "pointer",
"display": "=if(  ([$ContentType] == 'Folder' ), 'block', 'none')"
  },
  "children": [
    {
      "elmType": "span",
      "attributes": {
        "iconName": "FollowUser"
      },
      "style": {
        "padding-right": "6px"
      }
    },
    {
      "elmType": "span",
      "txtContent": "click to start"
    }
  ]
}

测试结果: 在此处输入图像描述


推荐阅读