【问题标题】:SharePoint lookup field format link to list item its referencingSharePoint 查找字段格式链接到列表项其引用
【发布时间】:2019-10-28 15:38:05
【问题描述】:

所以我有两个 SharePoint 列表: 1. 学生: - 姓名 - ... - ... 2.公司: - ... - 学生(查找字段,学生列表)

我想格式化这个“学生姓名”字段,更改文本颜色和背景颜色。 这有效,但现在该字段不再可点击。如果我删除自定义格式,我可以单击该字段值,然后它会将我带到该学生的详细信息。

我尝试在格式化json上添加href属性,但是不起作用,我无法点击。

这是我得到的:

{
"$schema": "https://developer.microsoft.com/json-schemas/sp/v2/column-formatting.schema.json",
"elmType": "div",
"txtContent": "@currentField.lookupValue",
"attributes": {
  "target": "_blank",
  "href": "='/sites/xxxx/Lists/Student/DispForm.aspx?Name=' + [$Student]"
},
"style": {
  "color": "#796BB1",
  "font-weight": "bold"
}

}

我还尝试将链接更改为“www.google.com”,以防该项目的链接错误。

【问题讨论】:

    标签: json sharepoint format lookup


    【解决方案1】:

    对于超链接,elmType 应该是“a”而不是“div”。你可以试试下面的代码:

    {
    "$schema": "https://developer.microsoft.com/json-schemas/sp/v2/column-formatting.schema.json",
    "elmType": "a",
    "txtContent": "@currentField.lookupValue",
     "attributes": {
          "href": {
             "operator": "+",
             "operands": [
                "/sites/michael/Lists/Student/DispForm.aspx?ID=",
                "@currentField.lookupId"
             ]
          },
          "target": "_blank"
       },
    "style": {
      "color": "#796BB1",
      "font-weight": "bold"
    }
    }
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-05-19
      • 1970-01-01
      • 2013-07-12
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多