Sharepoint在线列格式-以文本显示值

时间:2019-10-10 16:06:48

标签: json sharepoint conditional-formatting

  1. 在共享点列表中,我有一列名为“小时”,并将其设置为
  2. 我要插入一个4位数的值,例如2030、1015、2100等
  3. 我想将此值转换为“ 20:30”格式, “ 10:15”,“ 21:00”

如何在不使用计算列的情况下执行此操作? 可以使用JSON吗?

关于, 艾里奥·费尔南德斯(Elio Fernandes)

1 个答案:

答案 0 :(得分:0)

尝试在“小时”字段中使用以下JSON代码:

{
    "$schema": "https://developer.microsoft.com/json-schemas/sp/v2/column-formatting.schema.json",
    "elmType": "div",
    "txtContent": {
        "operator": "+",
        "operands": [
            "=substring(@currentField,0,2)",
            ":",
            "=substring(@currentField,2,4)"
        ]   
    }
}

对于数字列,请更改为:

{
  "$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)"
    ]
  }
}