我几乎已经完成了这项工作,但我只是需要一些列的格式方面的帮助。我有一个包含文本列的SharePoint列表,输入到该列的数据是一个版本号。JSON根据版本号创建一个红色/琥珀色/绿色圆圈,即小于6.4 =红色,6.4-6.9 =琥珀色,7+ =绿色。我还保留了文本值,这样就可以在圆内显示,正如您在这里看到的。SharePoint RAG column
我的问题是我不能让圆圈或文本在列中居中,正如你从我下面的代码中看到的那样,我通过使用填充来作弊,这得到了我想要的圆圈,但文本仍然挤在列的左边。如您所知,我的JSON有点麻烦,所以如果您有任何帮助,我们将不胜感激。
{
"elmType": "div",
"txtContent": "@currentField",
"attributes": {},
"style": {
"position": "absolute",
"left": "30%",
"top": "15%",
"color": "black",
"width": "40px",
"height": "35px",
"border-radius": "100%",
"background-color": {
"operator": "?",
"operands": [
{
"operator": ">",
"operands": [
"[$Software_x0020_version]",
"6.9.9"
]
},
"#00b300",
{
"operator": "?",
"operands": [
{
"operator": "<",
"operands": [
"[$Software_x0020_version]",
"6.3.9"
]
},
"#ec1313",
"#ffcc00"
]
}
]
}
},
"children": []
}发布于 2019-03-07 14:55:21
希望这能对你有所帮助。

{
"$schema": "https://developer.microsoft.com/json-schemas/sp/column-formatting.schema.json",
"elmType": "div",
"children": [
{
"elmType": "span",
"txtContent": "@currentField",
"attributes": {},
"style": {
"position": "absolute",
"left": "30%",
"top": "15%",
"color": "black",
"text-align": "center",
"width": "40px",
"height": "25px",
"border-radius": "100%",
"background-color": {
"operator": "?",
"operands": [
{
"operator": ">",
"operands": [
"[$Software_x0020_version]",
"6.9.9"
]
},
"#00b300",
{
"operator": "?",
"operands": [
{
"operator": "<",
"operands": [
"[$Software_x0020_version]",
"6.3.9"
]
},
"#ec1313",
"#ffcc00"
]
}
]
}
}
}
]
}更新:
更新后的格式:
{
"$schema": "https://developer.microsoft.com/json-schemas/sp/column-formatting.schema.json",
"elmType": "div",
"children": [
{
"elmType": "span",
"txtContent": "@currentField",
"attributes": {},
"style": {
"position": "absolute",
"left": "30%",
"top": "15%",
"color": "black",
"text-align": "center",
"width": "40px",
"height": "35px",
"align-items":"center",
"display":"inline-grid",
"border-radius": "100%",
"background-color": {
"operator": "?",
"operands": [
{
"operator": ">",
"operands": [
"[$Software_x0020_version]",
"6.9.9"
]
},
"#00b300",
{
"operator": "?",
"operands": [
{
"operator": "<",
"operands": [
"[$Software_x0020_version]",
"6.3.9"
]
},
"#ec1313",
"#ffcc00"
]
}
]
}
}
}
]
}

https://stackoverflow.com/questions/55028348
复制相似问题