首页 > 解决方案 > Sharepoint 列格式 - 基本

问题描述

我有一个非常基本的共享点列表,其中包含 3 列,如下所示:

日期1 | 日期2 | CalculatedDateDif(获取两个日期之间的月份)
01/01/2018 | 2018 年 1 月 3 日 | 2
2018 年 1 月 1 日 | 2018 年 1 月 4 日 | 3

我正在格式化 CalculatedDateDif 列,以使用默认的Microsoft JSON 代码在值小于或等于 2 时显示错误图标!以下:

{
  "$schema": "http://columnformatting.sharepointpnp.com/columnFormattingSchema.json",
  "debugMode": true,
  "elmType": "div",
  "attributes": {
    "class": "=if(@currentField <= 2,'sp-field-severity--warning', '')"
  },
  "children": [
    {
      "elmType": "span",
      "style": {
        "display": "inline-block",
        "padding": "0 4px"
      },
      "attributes": {
        "iconName": "=if(@currentField <= 2,'Error', '')"
      }
    },
    {
      "elmType": "span",
      "txtContent": "@currentField"
    }
  ]
}

出于某种奇怪的原因,它格式化计算列下的所有行并从计算列中删除值。

我试图用@CalculatedDateDif 替换@currentField,但没有运气。

我正在在线使用 Sharepoint。

标签: jsonsharepointformattingsharepoint-online

解决方案


进入列表设置,编辑CalculatedDateDif列,选择从该公式返回的数据类型为单行文本,然后保存。

在此处输入图像描述

在此处输入图像描述


推荐阅读