SharePoint自定义样式:JSON美化文件列表,点击无法展开分组
需求:在按「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
相关产品推荐
相关产品推荐

