首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >JSON中的多个格式化条件

JSON中的多个格式化条件
EN

Stack Overflow用户
提问于 2020-07-17 07:19:44
回答 1查看 857关注 0票数 0

我正在尝试对我的SharePoint列表使用一个简单的格式,使用JSON根据行索引和“审批状态”设置颜色的格式,一个简单的逻辑如下:

代码语言:javascript
复制
 If the status is approved:
      for each devise the index by 2 and if the reminder is equal to 0 show a slightly lighter color
                                ,otherwise a darker color (pretty standard formatting)

If the status is not Approved
    if Status is Pending, use orange
    if status is Rejected, use red

基于行索引的着色可以很好地工作,状态的着色也可以,但不能将这两者放在一起。

代码语言:javascript
复制
{
  "additionalRowClass": {
    "operator": ":",
    "operands": [
      {
      "operator": "&&", "operands": [
      { "operator": "==", "operands": ["[$_ModerationStatus]","Approved"] },
        "operator": "==",
        "operands": [
          {
            "operator": "%",
            "operands": [
              "@rowIndex",
              2
            ]
          },
          0
        ]
        ]
      },
      "sp-css-backgroundColor-neutralBackground",
      {
        "operator": ":",
        "operands": [
          {
           "operator": "&&", "operands": [
      { "operator": "==", "operands": ["[$_ModerationStatus]","Approved"] },
            "operator": "==",
            "operands": [
              {
                "operator": "%",
                "operands": [
                  "@rowIndex",
                  2
                ]
              },
              1
            ]
          },
          "sp-css-backgroundColor-noFill",
          ""
        ]
 
   
      
       
}
}
}
EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2020-07-17 16:20:47

下面是我的演示JSON代码,供您参考:

代码语言:javascript
复制
{
"schema": "https://developer.microsoft.com/json-schemas/sp/view-formatting.schema.json",
  "additionalRowClass":"=if([$Status]=='Approved',if(@rowIndex%2==0,'sp-css-backgroundColor-neutralBackground','sp-css-backgroundColor-noFill'),if([$Status]=='Pending','ms-bgColor-orangeLight',if([$Status]=='Rejected','ms-bgColor-red',''))"
}

测试结果:

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

https://stackoverflow.com/questions/62944890

复制
相关文章

相似问题

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