现代SharePoint列表窗体标题JSON格式

dgenwo3n  于 2023-06-25  发布在  其他
关注(0)|答案(2)|浏览(132)

我有一个SP列表形式头,工程除了一个部分。我有一个格式为数字的计算列。我想在标题中引用这一点,并使用它来拾取和着色一个图标。下面是我的Json的样子,但它似乎无法识别该列。

{
    "elmType": "div",
    "attributes": {
        "class": "ms-borderColor-neutralTertiary"
    },
    "style": {
        "width": "99%",
        "border-top-width": "0px",
        "border-bottom-width": "1px",
        "border-left-width": "0px",
        "border-right-width": "0px",
        "border-style": "solid",
        "margin-bottom": "15px",
        "background-color": "RGBA(0,95,131,1)"
    },
    "children": [
        {
            "elmType": "div",
            "style": {
                "display": "flex",
                "box-sizing": "border-box",
                "align-items": "center"
            },
            "children": [
                {
                    "elmType": "div",
                    "attributes": {
                        "iconName": "tagsolid",
                        "class": "ms-fontSize-42 ms-fontWeight-regular ms-fontColor-themePrimary",
                        "title": "Details"
                    },
                    "style": {
                        "flex": "none",
                        "padding": "0px",
                        "padding-left": "10px",
                        "height": "40px",
                        "color": "white"
                    }
                }
            ]
        },
        {
            "elmType": "div",
            "attributes": {
                "class": "ms-fontColor-neutralSecondary ms-fontWeight-bold ms-fontSize-24"
            },
            "style": {
                "box-sizing": "border-box",
                "width": "100%",
                "text-align": "left",
                "padding": "21px 12px",
                "overflow": "hidden",
                "color": "white"
            },
            "children": [
                {
                    "elmType": "div",
                    "txtContent": "=if([$Title]=='','New','Reject Tag Database - Tag #' + [$Title])"
                }
            ]
        },
        {
            "elmType": "div",
            "style": {
                "display": "flex",
                "box-sizing": "border-box",
                "align-items": "left"
            },
            "children": [
                {
                    "$schema": "https://developer.microsoft.com/json-schemas/sp/v2/column-formatting.schema.json",
                    "elmType": "div",
                    "attributes": {
                        "iconName": "=if([$Remaining_x0020_Balance] == 0,'boxcheckmarksolid','boxmultiplysolid')",
                        "class": "ms-fontSize-42 ms-fontWeight-regular ms-fontColor-themePrimary",
                        "title": "Details"
                    },
                    "debugMode": true,
                    "txtContent": "@currentField",
                    "style": {
                        "flex": "none",
                        "padding": "0px",
                        "padding-left": "10px",
                        "padding-top": "20px",
                        "height": "40px",
                        "visibility": "=if([$Title]=='','hidden','visible'",
                        "color": "=if([$Remaining_x0020_Balance] == 0, 'green', 'red')"
                    }
                },
                {
                    "elmType": "div",
                    "attributes": {
                        "class": "ms-fontColor-neutralSecondary ms-fontWeight-bold ms-fontSize-24"
                    },
                    "style": {
                        "box-sizing": "border-box",
                        "width": "100%",
                        "text-align": "left",
                        "padding": "21px 5px",
                        "overflow": "hidden",
                        "color": "white",
                        "visibility": "=if([$Title]=='','hidden','visible'"
                    },
                    "children": [
                        {
                            "elmType": "div",
                            "txtContent": "Closed"
                        }
                    ]
                }
            ]
        },
        {
            "elmType": "div",
            "attributes": {
                "class": "ms-fontColor-neutralSecondary ms-fontWeight-bold ms-fontSize-24"
            },
            "style": {
                "box-sizing": "border-box",
                "width": "100%",
                "text-align": "right",
                "padding": "21px 12px",
                "overflow": "hidden",
                "color": "white"
            },
            "children": [
                {
                    "elmType": "div",
                    "txtContent": "=if([$Title]=='','','Part Number : '+[$PartNumber])"
                },
                {
                    "elmType": "div",
                    "txtContent": "=if([$Title]=='','','Tag Quantity : '+[$Quantity])"
                }
            ]
        }
    ]
}

有谁能看出什么是错的,为什么它不起作用?它应该读为,如果剩余余额等于0给予绿色复选框,否则给出红色乘法框。
谢谢
编辑:我已经用完整的Json更新了代码,因为我认为这就是问题所在。我肯定这是一个混乱的地方,我只是拼凑起来一点一点。

yeotifhr

yeotifhr1#

我有测试下面的JSON格式化和作品

{
  "$schema": "https://developer.microsoft.com/json-schemas/sp/v2/column-formatting.schema.json",
  "elmType": "div",
  "attributes": {
    "iconName": "=if([$Remaining_x0020_Balance] == 0,'boxcheckmarksolid','boxmultiplysolid')",
    "class": "ms-fontSize-42 ms-fontWeight-regular ms-fontColor-themePrimary",
    "title": "Details"
  },
  "debugMode": true,
  "txtContent": "@currentField",
  "style": {
    "flex": "none",
    "padding": "0px",
    "padding-left": "10px",
    "height": "40px",
    "color": "=if([$Remaining_x0020_Balance] == 0, 'green', 'red')"
  }
}

mctunoxg

mctunoxg2#

我已经测试了这一点,从我的结束,我能够重现这个问题。我认为这是在JSON表单格式中使用计算列时的一个错误。
计算的列值在页面上下文中可用,但不显示在表单标题中:

我在这里提出了一个新的bug/问题:JSON Form formatting: Unable to use the calculated column value in header/footer layout customization。希望微软在不久的将来会修复这个问题。

相似线程:从SPO列表中获取Name列的值,以便在标头中进行JSON格式设置

此外,您必须在JSON格式中使用列的内部名称。您可以按照本文的说明获取列的内部名称:How to find the Internal name of columns in SharePoint Online?

相关问题