You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

SharePoint自定义样式:JSON美化文件列表,点击无法展开分组

SharePoint文档库分组视图自定义配置

需求:在按「File Type」列分组的文档库视图中,移除默认的「File Type: 分组名称」标签格式,仅展示分组名称及对应项目数量,同时禁用分组标题的展开/收起点击操作。

修改后的自定义JSON代码如下:

{
  "$schema": "https://developer.microsoft.com/json-schemas/sp/v2/row-formatting.schema.json",
  "groupProps": {
    "headerFormatter": {
      "elmType": "div",
      "style": {
        "display": "flex",
        "align-items": "center",
        "gap": "6px",
        "padding-left": "12px",
        "font-size": "16px",
        "font-weight": "400",
        "cursor": "default",
        "white-space": "nowrap",
        "text-overflow": "ellipsis",
        "width": "100%"
      },
      "children": [
        {
          "elmType": "div",
          "children": [
            {
              "elmType": "span",
              "style": {
                "padding": "5px 5px 5px 5px"
              },
              "txtContent": "@group.fieldData.displayValue"
            }
          ]
        },
        {
          "elmType": "div",
          "style": {
            "margin-left": "4px",
            "display": "flex",
            "align-items": "center"
          },
          "children": [
            {
              "elmType": "span",
              "txtContent": " ("
            },
            {
              "elmType": "span",
              "txtContent": "@group.count"
            },
            {
              "elmType": "span",
              "txtContent": ")"
            }
          ]
        }
      ]
    }
  }
}

关键修改说明:

  • 移除了所有customRowAction节点,彻底取消点击分组标题触发展开/收起的逻辑
  • 删除了原配置中role="button"、tabindex、title等按钮交互相关属性,让分组标题仅作为纯文本展示
  • 将style里的cursor从pointer改为default,消除鼠标悬停时的可点击提示
  • 保留了核心的分组名称(@group.fieldData.displayValue)和项目数量(@group.count)展示逻辑,同时移除了默认的「File Type:」前缀

内容的提问来源于stack exchange,提问作者user3841443

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.06.12 10:52:36