json - Sharepoint Online - JSON 列格式
问题描述
我有 Michael Han 给出的以下代码,它工作得很好。它将像“2030”这样的数字格式化为“20:30”
{
"$schema": "https://developer.microsoft.com/json-schemas/sp/v2/column-formatting.schema.json",
"elmType": "div",
"txtContent": {
"operator": "+",
"operands": [
"=substring(toString(@currentField),0,2)",
":",
"=substring(toString(@currentField),2,4)"
]
}
}
我需要将此列用作另一个列表的查找列,因此我粘贴了此代码并在https://github.com/SharePoint/sp-dev-中提到的新查找列中将@currentField替换为@currentField.LookupValue docs/blob/master/docs/declarative-customization/column-formatting.md
结果只是显示“ : ”。我必须做些什么才能让它发挥作用?
问候, 埃利奥·费尔南德斯
解决方案
首先,您需要使用@currentField.lookupValue而不是@currentField.LookupValue,lookupValue 的第一个字符应该是小写的。并且代码仅在父列表中的字段是单行文本时才有效。
如果父列表中的字段类型是数字,则需要将代码更改为:
{
"$schema": "https://developer.microsoft.com/json-schemas/sp/v2/column-formatting.schema.json",
"elmType": "div",
"txtContent": {
"operator": "+",
"operands": [
"=substring(toString(@currentField.lookupValue),0,1)",
"=substring(toString(@currentField.lookupValue),2,3)",
":",
"=substring(toString(@currentField.lookupValue)3,5)"
]
}
}
推荐阅读
- python - 更改某个文件时如何使用macbook automator自动运行python脚本?
- javascript - 使用经纬度获取城市名称
- java - 如何在sqlite java android上删除1行列后重置自动增量值?
- c++ - 入队函数
- apache - 为同一台机器中的其他虚拟主机共享 Apache 授权
- python - 这是什么数据类型以及如何使用 python 将其转换为可读格式?
- java - 寻找一种在java中搜索数组的方法
- xcode - NSTooltip 自动释放崩溃
- python - 如何在 ubuntu 20.04 上安装 python3-pip
- php - WP / 阿贾克斯 | Jquery Dropzone js文件上传调用两次请求