首页 > 解决方案 > 如何更改视图中 Sharepoint Online 列表列标题的背景和字体颜色?

问题描述

我正在尝试更改 Sharepoint Online 列表中视图中列标题的颜色,最好使用 Microsoft 为格式化视图提供的 JSON 模式。

我发现 Microsoft 的文档概述了许多有趣的示例,例如我可以使用 "hideColumnHeader": true 完全隐藏列标题,或者我可以更改组标题的颜色,但似乎没有任何文档说明如何更改列标题本身的背景颜色。

https://docs.microsoft.com/en-us/sharepoint/dev/declarative-customization/view-formatting

我想要实现的目标非常简单。我想更改列标题背景颜色和字体颜色,并为不同的列设置不同的颜色,就像在 Excel 中可以轻松做到的那样:

我希望 Sharepoint 列表视图看起来像的示例

这可能使用 JSON 模式吗?

在此先感谢您的时间。

标签: sharepointsharepoint-onlinesharepoint-list

解决方案


我最近发现并为行值实现了这一点,它也可能有助于列标题:

````  {

“$schema”:“https://developer.microsoft.com/json-schemas/sp/v2/column-formatting.schema.json”,“elmType”:“div”,“txtContent”:“@currentField”, "style": { "color": "=if(@currentField == 'Purple 1', '#ffffff','')", "background-color": "=if(@currentField == 'Gold 1' , '#D7AC11', if(@currentField == 'Gold 2', '#DBBA2F', if(@currentField == 'Gold 3', '#F1D531', if(@currentField == 'Aqua 1', ' #008198', if(@currentField == 'Aqua 2', '#00bed8', if(@currentField == 'Aqua 3', '#75C7B9', if(@currentField == 'Green', '#84b638' , if(@currentField == '灰色 1', '#808285', if(@currentField == '灰色 2','#9d9fa2', if(@currentField == '灰色 3', '#bcbec0', if(@currentField == '灰色 4', '#e6e7e8', if(@currentField == '红色', '#ca4e28 ', if(@currentField == 'Purple 1', '#492f92', if(@currentField == 'Purple 2', '#9c8dc3', '' ) ) )) ) ) ) ))))) "

} }





推荐阅读