【发布时间】:2020-01-24 03:29:40
【问题描述】:
我希望有人能提供帮助 - 我对 JSON 或编码一无所知。
我有一个共享点在线列表,我已将其格式化为根据每个项目中显示的文本显示不同的颜色。 我现在也希望在列中添加图标。例如,如果状态为“新建”,我希望它是我在代码中选择的颜色,同时还从 Office UI Fabric 添加一个 + 图标。
以下是我使用的两个代码,它们分别工作,我想将它们结合在一起。
{
"$schema": "https://developer.microsoft.com/json-schemas/sp/v2/column-formatting.schema.json",
"elmType": "div",
"children": [
{
"elmType": "span",
"style": {
"display": "inline-block",
"padding": "0 4px"
},
"attributes": {
"iconName": "=if(@currentField == 'Completed', 'CheckMark', if(@currentField == 'Draft phase', 'Forward', if(@currentField == 'Approval phase', 'Error', if(@currentField == 'On hold', 'Warning', 'ErrorBadge'))))"
}
},
{
"elmType": "span",
"txtContent": "@currentField"
}
]
}
{
"elmType": "div",
"style": {
"padding": "0 4px"
},
"attributes": {
"class": {
"operator": ":",
"operands": [
{
"operator": "==",
"operands": [
{
"operator": "toLowerCase",
"operands": [
"@currentField"
]
},
{
"operator": "toLowerCase",
"operands": [
"New"
]
}
]
},
"sp-css-backgroundColor-blueBackground07",
{
"operator": ":",
"operands": [
{
"operator": "==",
"operands": [
{
"operator": "toLowerCase",
"operands": [
"@currentField"
]
},
{
"operator": "toLowerCase",
"operands": [
"Draft phase"
]
}
]
},
"sp-css-backgroundColor-warningBackground",
{
"operator": ":",
"operands": [
{
"operator": "==",
"operands": [
{
"operator": "toLowerCase",
"operands": [
"@currentField"
]
},
{
"operator": "toLowerCase",
"operands": [
"Approval phase"
]
}
]
},
"sp-css-backgroundColor-successBackground",
{
"operator": ":",
"operands": [
{
"operator": "==",
"operands": [
{
"operator": "toLowerCase",
"operands": [
"@currentField"
]
},
{
"operator": "toLowerCase",
"operands": [
"Ready for upload"
]
}
]
},
"sp-css-backgroundColor-blockingBackground",
{
"operator": ":",
"operands": [
{
"operator": "==",
"operands": [
{
"operator": "toLowerCase",
"operands": [
"@currentField"
]
},
{
"operator": "toLowerCase",
"operands": [
"Completed"
]
}
]
},
"sp-css-backgroundColor-neutralBackground",
{
"operator": ":",
"operands": [
{
"operator": "==",
"operands": [
{
"operator": "toLowerCase",
"operands": [
"@currentField"
]
},
{
"operator": "toLowerCase",
"operands": [
"On hold"
]
}
]
},
"sp-css-backgroundColor-errorBackground",
""
]
}
]
}
]
}
]
}
]
}
]
}
},
"txtContent": "@currentField"
}
【问题讨论】:
标签: javascript json sharepoint-online