提问人:Alfonzo 提问时间:12/23/2021 最后编辑:Alfonzo 更新时间:12/24/2021 访问量:1345
用于 Sharepoint online 的 JSON/Excel 格式的拆分函数
Split function in JSON/Excel format for Sharepoint online
问:
我正在使用 sharepoint online 作为图像库。我使用“关键字”来标记每张图片。该字段是一串带分隔符的值,如下所示:
keyword1;keyword2;keyword3
我想通过使用分号分隔符拆分字符串并在其自己的范围内显示每个关键字来格式化此字段值,因此它看起来像这样:
(关键字 1)(关键字 2)(关键字 3)
我不确定我是否需要使用计算列来执行此操作,或者是否可能?我尝试使用“forEach”,但我似乎无法遍历这些项目 - 它们只是在单个跨度中呈现为单个值?
这是我目前正在使用的:
{
"$schema": "https://developer.microsoft.com/json-schemas/sp/view-formatting.schema.json",
"hideSelection": true,
"tileProps": {
"height": "300",
"width": "300",
"formatter": {
"elmType": "div",
"style": {
"display": "flex",
"flex-wrap": "wrap",
"align-items": "stretch",
"box-shadow": "0 1.6px 3.6px 0 #00000022, 0 0.3px 0.9px 0 #0000001c",
"min-width": "150px",
"width": "100%",
"margin-bottom": "0",
"border-radius": "3px",
"margin": "0 2px",
"background-color": "#fbfbfb",
"height": "350px"
},
"children": [
{
"elmType": "div",
"style": {
"display": "flex",
"flex-wrap": "wrap",
"position": "relative",
"padding-bottom": "30px",
"width": "100%"
},
"children": [
{
"elmType": "div",
"style": {
"width": "100%",
"background-color": "#e4e4e4",
"overflow": "hidden",
"height": "200px",
"display": "flex",
"align-items": "center",
"justify-content": "center",
"position": "relative"
},
"children": [
{
"elmType": "div",
"style": {
"oveflow": "=if([$File_x0020_Type] == '', 'auto', 'hidden')"
},
"children": [
{
"elmType": "img",
"style": {
"width": "=if([$File_x0020_Type] == '', '100%', '0'",
"height": "=if([$File_x0020_Type] == '', '100px', '0'"
},
"attributes": {
"src": "=if([$File_x0020_Type] == '', 'https://spoprod-a.akamaihd.net/files/fabric/office-ui-fabric-react-assets/foldericons-fluent/folder-large_frontplate_nopreview.svg', '')"
}
},
{
"elmType": "img",
"style": {
"width": "100%",
"height": "100%",
"display": "=if([$File_x0020_Type] == '', 'none', '')"
},
"attributes": {
"src": "@thumbnail.300x300"
},
"defaultHoverField": "[$FileLeafRef]"
}
]
}
]
},
{
"elmType": "div",
"style": {
"margin": "15px 0",
"position": "absolute",
"top": "200px",
"width": "100%"
},
"attributes": {
"class": "ms-fontSize-14 ms-fontWeight-semibold"
}
},
{
"elmType": "div",
"style": {
"display": "flex",
"flex-wrap": "wrap",
"padding": "0 16px",
"line-height": "20px",
"width": "100%"
},
"children": [
{
"elmType": "div",
"style": {
"display": "inline-block",
"flex": "1 0 100%"
},
"children": [
{
"elmType": "div",
"style": {
"color": "#a7a7a7",
"font-weight": "bold"
},
"txtContent": "Keywords"
},
{
"elmType": "div",
"children": [
{
"forEach": "kwIterator in @currentField",
"elmType": "div",
"txtContent": "[$kwIterator]",
"attributes": {
"class": "ms-bgColor-themePrimary ms-fontColor-white",
"title": "='keyword:' + =[$kwIterator]"
},
"style": {
"width": "16px",
"height": "16px",
"text-align": "center",
"margin": "1px"
}
}
]
}
]
},
{
"elmType": "div",
"style": {
"display": "inline-block",
"flex": "1 0 34%"
},
"children": [
{
"elmType": "div",
"style": {
"color": "#a7a7a7"
},
"txtContent": "=if([$AverageRating] >= 5, '*****', if([$AverageRating] >= 4, '****', if([$AverageRating] >= 3, '***', if([$AverageRating] >= 2, '**', if([$AverageRating] >= 1, '*', 'no rating'))))"
},
{
"elmType": "div",
"style": {
"color": "#a7a7a7",
"font-size": "40px"
},
"txtContent": "=if([$AverageRating] >= 5, '*****', if([$AverageRating] >= 4, '****', if([$AverageRating] >= 3, '***', if([$AverageRating] >= 2, '**', if([$AverageRating] >= 1, '*', '-'))))"
}
]
}
]
}
]
}
]
}
}
}
任何用于循环访问分隔值列表的指针将不胜感激。
答:
1赞
EchoDu_MSFT
12/24/2021
#1
根据我的研究,forEach 不支持多行文本类型。
来自这篇文章:
循环中使用的字段必须是启用了多值选项的受支持字段类型:Person、Lookup 和 Choice。
由于多行文本中的所有文本都被识别为一个整体,因此我们无法通过“;”将其拆分,并使用 Json 在它们之间添加链接中断。
评论