首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >SharePoint列格式使用JSON - RAG状态灯与文本,如何让它正确对齐?

SharePoint列格式使用JSON - RAG状态灯与文本,如何让它正确对齐?
EN

Stack Overflow用户
提问于 2019-03-07 00:54:54
回答 1查看 817关注 0票数 0

我几乎已经完成了这项工作,但我只是需要一些列的格式方面的帮助。我有一个包含文本列的SharePoint列表,输入到该列的数据是一个版本号。JSON根据版本号创建一个红色/琥珀色/绿色圆圈,即小于6.4 =红色,6.4-6.9 =琥珀色,7+ =绿色。我还保留了文本值,这样就可以在圆内显示,正如您在这里看到的。SharePoint RAG column

我的问题是我不能让圆圈或文本在列中居中,正如你从我下面的代码中看到的那样,我通过使用填充来作弊,这得到了我想要的圆圈,但文本仍然挤在列的左边。如您所知,我的JSON有点麻烦,所以如果您有任何帮助,我们将不胜感激。

代码语言:javascript
复制
{
  "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": []
}
EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2019-03-07 14:55:21

希望这能对你有所帮助。

代码语言:javascript
复制
{
  "$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"
              ]
            }
          ]
        }
      }
    }
  ]
}

更新:

更新后的格式:

代码语言:javascript
复制
{
  "$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"
              ]
            }
          ]
        }
      }
    }
  ]
}

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/55028348

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档