SharePoint Online列表视图JSON格式失效,编辑表单正常
问题出在列表视图对background-color空值的解析逻辑上——表单能识别空字符串''为无背景,但列表视图不行,得换成transparent(透明)或者inherit(继承父背景)才能生效。
修改后的JSON代码如下:
{ "$schema": "https://developer.microsoft.com/json-schemas/sp/v2/column-formatting.schema.json", "elmType": "div", "txtContent": "@currentField", "style": { "color": "=if( [$Step5Complete] == true, '#000000','#FFFFFF')", "font-weight": "bold", "background-color": "=if([$Step5Complete] == true,'transparent', if(@currentField >= @now + 1209600000, 'green', if(@currentField < @now, 'red','yellow')))" } }
核心修改点:将原代码中[$Step5Complete] == true对应的背景色值从''替换为'transparent',这样列表视图会正确渲染透明背景,同时保持表单中的显示逻辑不变。
内容的提问来源于stack exchange,提问作者user23616112
相关产品推荐
相关产品推荐

