首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >甘特图中的Sharepoint脚本not部件不起作用

甘特图中的Sharepoint脚本not部件不起作用
EN

Stack Overflow用户
提问于 2019-12-11 21:10:28
回答 2查看 175关注 0票数 0

我不明白为什么,但我从sharepoint上的微软项目构建了甘特图,有很多子任务,我想默认情况下隐藏子任务。

不幸的是,我放在甘特图上面的任何脚本都不能工作,也不能产生任何东西……

我试过每种类型的链接,都不起作用。我不能理解这个问题。我尝试了这里解释的方法,使用该代码:Why is this jQuery not working on my Sharepoint page?但nothing work enter image description here

代码语言:javascript
复制
<script
      src="https://code.jquery.com/jquery-3.2.1.min.js"
      integrity="sha256-hwg4gsxgFZhOsEEamdOYGBf13FyQuiTwlAQgxVSNgt4="
      crossorigin="anonymous"></script>

<script>
jQuery(document).ready(function(){
    SP.SOD.executeFunc('sp.js', 'SP.ClientContext', run);
});

function run(){
    jQuery('div[class="ms-vb  itx"]').find('span[style]').each(function(){
        if(jQuery(this).css('margin-left')!="0px"){
            jQuery(this).parent().parent().parent().hide();
        }
    });
}
</script>

谢谢

EN

回答 2

Stack Overflow用户

发布于 2019-12-11 23:57:33

我在一个新网站上重新安装了所有内容,现在它可以正常工作了。非常奇怪的问题。

我想知道是否也可以更改任务列表视图中的格式:

代码语言:javascript
复制
{
  "$schema": "http://columnformatting.sharepointpnp.com/columnFormattingSchema.json",
  "elmType": "div",
  "attributes": {
    "class": {
      "operator": "?",
      "operands": [
        {
          "operator": "==",
          "operands": [
            "@currentField",
            "No Issues"
          ]
        },
        "sp-field-severity--good",
        {
          "operator": "?",
          "operands": [
            {
              "operator": "==",
              "operands": [
                "@currentField",
                "Inactive"
              ]
            },
            "sp-field-severity--low",
            {
              "operator": "?",
              "operands": [
                {
                  "operator": "==",
                  "operands": [
                    "@currentField",
                    "Warning"
                  ]
                },
                "sp-field-severity--warning",
                {
                  "operator": "?",
                  "operands": [
                    {
                      "operator": "==",
                      "operands": [
                        "@currentField",
                        "In Review"
                      ]
                    },
                    "sp-field-severity--severeWarning",
                    "sp-field-severity--blocked"
                  ]
                }
              ]
            }
          ]
        }
      ]
    }
  },
  "children": [
    {
      "elmType": "span",
      "style": {
        "display": "inline-block",
        "padding-left": "4px"
      },
      "attributes": {
        "iconName": {
          "operator": "?",
          "operands": [
            {
              "operator": "==",
              "operands": [
                "@currentField",
                "No Issues"
              ]
            },
            "CheckMark",
            {
              "operator": "?",
              "operands": [
                {
                  "operator": "==",
                  "operands": [
                    "@currentField",
                    "Inactive"
                  ]
                },
                "Forward",
                {
                  "operator": "?",
                  "operands": [
                    {
                      "operator": "==",
                      "operands": [
                        "@currentField",
                        "In Review"
                      ]
                    },
                    "Error",
                    {
                      "operator": "?",
                      "operands": [
                        {
                          "operator": "==",
                          "operands": [
                            "@currentField",
                            "Warning"
                          ]
                        },
                        "Warning",
                        "ErrorBadge"
                      ]
                    }
                  ]
                }
              ]
            }
          ]
        }
      }
    },
    {
      "elmType": "span",
      "txtContent": "@currentField",
      "style": {
        "padding-left": "10px",
        "font-weight": "bold"
      }
    }
  ]
}

就像这样(这段代码使用的是列表,而不是列出应用程序的任务,我不明白为什么)

票数 0
EN

Stack Overflow用户

发布于 2019-12-12 14:38:47

下面的JSON格式供你参考,它也适用于现代任务列表。

代码语言:javascript
复制
{
    "$schema": "https://developer.microsoft.com/json-schemas/sp/v2/column-formatting.schema.json",
    "elmType": "div",
    "style": {
        "display": "table",
        "width": "100%"
    },
    "attributes": {
        "class": "=if(@currentField == 'No Issues', 'sp-field-severity--good', if(@currentField == 'Inactive', 'sp-field-severity--low', if(@currentField == 'Warning', 'sp-field-severity--warning', if(@currentField == 'In Review', 'sp-field-severity--severeWarning', 'sp-field-severity--blocked')))) + ' ms-fontColor-neutralSecondary'"
    },
    "children": [
        {
            "elmType": "span",
            "style": {
                "padding": "0 4px",
                "display": "table-cell",
                "vertical-align": "middle",
                "width":"16px"
            },
            "attributes": {
                "iconName": "=if(@currentField == 'No Issues', 'CheckMark', if(@currentField == 'Inactive', 'Forward', if(@currentField == 'In Review', 'Error', if(@currentField == 'Warning', 'Warning', 'ErrorBadge'))))"
            }
        },
        {
            "elmType": "span",
            "txtContent": "@currentField",
            "style": {
                "display": "table-cell",
                "font-weight": "bold",
                "padding-left": "10px",
                "vertical-align": "middle"
            }
        }
    ]
}

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

https://stackoverflow.com/questions/59286580

复制
相关文章

相似问题

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