SharePoint 联系人卡片列表视图格式不显示内容

Posted

技术标签:

【中文标题】SharePoint 联系人卡片列表视图格式不显示内容【英文标题】:SharePoint Contact Card List View formatting is not displaying content 【发布时间】:2019-12-06 12:27:42 【问题描述】:

我正在尝试通过定制 github 上提供的示例将列表视图格式化为联系人卡片格式。我设法让联系人卡片显示为灰色框,但无法让项目详细信息显示在框中。

尝试了很多不同的东西。更改了列名,仅包含一列的 json 以使其正确。尝试作为 div 和 span。列名中没有空格。列名中的空格。 % 列名中有空格的地方。我得到的最好的是对象对象或作为“a”elmtype 的最后一个孩子,显示为超链接,但没有其他字段。也不能在条目上方的卡片中显示列标题。


    "$schema":"https://developer.microsoft.com/json-schemas/sp/view-formatting.schema.json",
    "hideSelection":true,
    "hideListHeader":true,
    "rowFormatter":
        "elmType":"div",
        "style":
            "float":"left",
            "display":"flex",
            "flex-wrap":"wrap",
            "flex-direction":"column",
            "align-items":"stretch",
            "justify-content":"space-around",
            "min-width":"600px",
            "min-height":"486px",
            "border-radius":"8px",
            "margin-right":"10px",
            "margin-bottom":"10px",
            "box-shadow":"2px 2px 4px darkgrey"
        ,
        "attributes":
            "class":"ms-bgColor-neutralLighterAlt ms-bgColor-neutralLight--hover ms-fontColor-themePrimary--hover"
        ,
        "children":[
            
                "elmType":"div",
                "txtContent":"[$FirstName]",
                "style":
                    "color":"black",
                    "font-style":"normal",
                    "font-size":"10px",
                    "display":"block",
                    "width":"250px",
                    "height":"50px",
                    "border-radius":"50%",
                    "word-wrap":"initial",
                    "white-space":"nowrap",
                    "flex-grow":"1",
                    "flex-direction":"column",
                    "flex-wrap":"wrap"
                
            
        ]
    

上面的示例只是我原始列表视图中的列标题之一。条目的名字没有出现在框中

【问题讨论】:

【参考方案1】:

"$schema":"https://developer.microsoft.com/json-schemas/sp/view-formatting.schema.json",
"hideSelection":true,
"hideListHeader":true,
"rowFormatter":
    "elmType":"div",
    "style":
        "float":"left",
        "flex-wrap":"wrap",
        "flex-direction":"row",
        "width":"600px",
        "height":"900px",
        "border-radius":"8px",
        "margin-right":"10px",
        "margin-bottom":"10px",
        "box-shadow":"2px 2px 4px darkgrey"
    ,
    "attributes":
        "class":"ms-bgColor-neutralLighterAlt ms-bgColor-neutralLight--hover ms-fontColor-themePrimary--hover"
    ,
    "children":[
        
            "elmType":"div",
            "__comment:":"DIV 1",
            "style":
                "flex-grow":"1",
                "display":"flex",
                "flex-direction":"column",
                "flex-wrap":"nowrap"
            ,
            "children":[
                
                    "elmType":"div",
                    "txtContent":"=[$FullName]",
                    "style":
                        "display":"block",
                        "font-size":"16px",
                        "font-weight":"bold",
                        "padding-top":"20px",
                        "margin-left":"10px",
                        "margin-right":"10px"
                    
                ,
                
                    "elmType":"div",
                    "txtContent":"Job Title",
                    "style":
                        "display":"block",
                        "font-size":"14px",
                        "font-weight":"bold",
                        "padding-top":"20px",
                        "margin-left":"10px",
                        "margin-right":"10px"
                    
                ,
                
                    "elmType":"div",
                    "txtContent":"=[$JobTitle]",
                    "style":
                        "display":"block",
                        "font-size":"12px",
                        "font-color":"red",
                        "font-weight":"normal",
                        "padding-top":"10px",
                        "margin-left":"10px",
                        "margin-right":"10px"
                    
                ,
                
                    "elmType":"div",
                    "txtContent":"Career Interests",
                    "style":
                        "display":"block",
                        "font-size":"14px",
                        "font-weight":"bold",
                        "padding-top":"20px",
                        "margin-left":"10px",
                        "margin-right":"10px",
                        "margin-top":"10px",
                        "margin-bottom":"10px"
                    
                ,
                
                    "elmType":"div",
                    "txtContent":"=[$CareerInterests]",
                    "style":
                        "display":"block",
                        "font-size":"12px",
                        "font-weight":"normal",
                        "padding-top":"10px",
                        "margin-left":"10px",
                        "margin-right":"10px"
                    
                ,
                
                    "elmType":"div",
                    "txtContent":"Beginner",
                    "style":
                        "display":"block",
                        "font-size":"14px",
                        "font-weight":"bold",
                        "padding-top":"20px",
                        "margin-left":"10px",
                        "margin-right":"10px"
                    
                ,
                
                    "elmType":"div",
                    "txtContent":"=[$SkillLevelBeginner]",
                    "style":
                        "display":"block",
                        "font-size":"12px",
                        "font-weight":"normal",
                        "padding-top":"10px",
                        "margin-left":"10px",
                        "margin-right":"10px"
                    
                ,
                
                    "elmType":"div",
                    "txtContent":"Intermediate",
                    "style":
                        "display":"block",
                        "font-size":"14px",
                        "font-weight":"bold",
                        "padding-top":"20px",
                        "margin-left":"10px",
                        "margin-right":"10px"
                    
                ,
                
                    "elmType":"div",
                    "txtContent":"=[$SkillLevelIntermediate]",
                    "style":
                        "display":"block",
                        "font-size":"12px",
                        "font-weight":"normal",
                        "padding-top":"10px",
                        "margin-left":"10px",
                        "margin-right":"10px"
                    
                ,
                
                    "elmType":"div",
                    "txtContent":"Advanced",
                    "style":
                        "display":"block",
                        "font-size":"14px",
                        "font-weight":"bold",
                        "padding-top":"20px",
                        "margin-left":"10px",
                        "margin-right":"10px"
                    
                ,
                
                    "elmType":"div",
                    "txtContent":"=[$SkillLevelAdvanced]",
                    "style":
                        "display":"block",
                        "font-size":"12px",
                        "font-weight":"normal",
                        "padding-top":"10px",
                        "margin-left":"10px",
                        "margin-right":"10px"
                    
                ,
                
                    "elmType":"div",
                    "txtContent":"Previous Roles",
                    "style":
                        "display":"block",
                        "font-size":"14px",
                        "font-weight":"bold",
                        "padding-top":"20px",
                        "margin-left":"10px",
                        "margin-right":"10px"
                    
                ,
                
                    "elmType":"div",
                    "txtContent":"=[$PreviousRoles]",
                    "style":
                        "display":"block",
                        "font-size":"12px",
                        "font-weight":"normal",
                        "padding-top":"10px",
                        "margin-left":"10px",
                        "margin-right":"10px"
                    
                ,
                
                    "elmType":"div",
                    "txtContent":"Qualifications",
                    "style":
                        "display":"block",
                        "font-size":"14px",
                        "font-weight":"bold",
                        "padding-top":"20px",
                        "margin-left":"10px",
                        "margin-right":"10px"
                    
                ,
                
                    "elmType":"div",
                    "txtContent":"Primary Qualifications",
                    "style":
                        "display":"block",
                        "font-size":"14px",
                        "font-weight":"bold",
                        "padding-top":"20px",
                        "margin-left":"10px",
                        "margin-right":"10px"
                    
                ,
                
                    "elmType":"div",
                    "txtContent":"=[$PrimaryQualifications]",
                    "style":
                        "display":"block",
                        "font-size":"12px",
                        "font-weight":"normal",
                        "padding-top":"10px",
                        "margin-left":"10px",
                        "margin-right":"10px"
                    
                ,
                
                    "elmType":"div",
                    "txtContent":"=[$PrimaryDisciplineMajor]",
                    "style":
                        "display":"block",
                        "font-size":"12px",
                        "font-weight":"normal",
                        "padding-top":"10px",
                        "margin-left":"10px",
                        "margin-right":"10px"
                    
                ,
                
                    "elmType":"div",
                    "txtContent":"Additional Qualifications",
                    "style":
                        "display":"block",
                        "font-size":"14px",
                        "font-weight":"bold",
                        "padding-top":"10px",
                        "margin-left":"10px",
                        "margin-right":"10px"
                    
                ,
                
                    "elmType":"div",
                    "txtContent":"=[$AdditionalQualifications]",
                    "style":
                        "display":"block",
                        "font-size":"12px",
                        "font-weight":"normal",
                        "padding-top":"10px",
                        "margin-left":"10px",
                        "margin-right":"10px"
                    
                ,
                
                    "elmType": "a",
                        "style": 
                        "border": "none",
                        "padding-top": "15px",
                        "background-color": "transparent",
                        "color": "#0078d7",
                        "margin-left":"10px",
                        "margin-bottom": "20px",
                        "text-align": "left",
                        "cursor": "pointer",
                        "display": "=if([$LinkedIn]=='','none','')"
                    ,
                    "attributes": 
                        "target": "_blank",
                        "iconName": "LinkedInLogo",
                        "href": "[$LinkedIn]"
                    
                ,
                
                    "elmType": "a",
                        "style": 
                        "border": "none",
                        "display":"float",
                        "padding-top": "15px",
                        "background-color": "transparent",
                        "color": "#0078d7",
                        "margin-left":"10px",
                        "margin-bottom": "20px",
                        "text-align": "left",
                        "cursor": "pointer"
                    ,
                    "attributes": 
                        "target": "_blank",
                        "iconName": "CreateMailRule",
                        "href": "[$FullName.email]",
                        "title": "Email"
                    
                
            ]
        
    ]

【讨论】:

取得了胜利 - 现在只需弄清楚如何显示 FullName 并从使用 Microsoft 帐户名称照片和电子邮件地址详细信息的 Person 列类型中提取。

以上是关于SharePoint 联系人卡片列表视图格式不显示内容的主要内容,如果未能解决你的问题,请参考以下文章

SharePoint Online 格式化列表视图

在 Sharepoint 2013 sharepoint 托管应用程序中显示 Lync 联系人

Sharepoint Online / 365 - 从列表视图中删除多个附加列和显示条目的“查看条目”

以编程方式将列表视图添加到 Sharepoint 2013 C# 中的所有列表

SharePoint Server 2019 中的日历列表视图

如何在运行时生成卡片视图以显示来自 Sqlite 的数据?