【问题标题】:Sharepoint script webpart in Gantt not working甘特图中的 Sharepoint 脚本 webpart 不起作用
【发布时间】:2020-04-04 18:46:06
【问题描述】:

我不明白为什么,但是我在sharepoint上从ms项目构建了甘特图,有很多子任务,我想默认隐藏子任务。

不幸的是,我放在甘特图上方的任何脚本都不起作用并产生任何东西......

我尝试了所有类型的链接,但没有任何效果......我无法理解问题...... 我尝试了这里解释的内容,代码:Why is this jQuery not working on my Sharepoint page? 但没有任何工作enter image description here

<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>

谢谢

【问题讨论】:

    标签: javascript sharepoint web-parts content-query-web-part


    【解决方案1】:

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

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

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

    类似的东西(此代码适用于列表,但不适用于列出任务的应用程序,看不出原因)

    【讨论】:

      【解决方案2】:

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

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

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2012-07-26
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多