【问题标题】:Unable to select list item with horizontal view format无法选择具有水平视图格式的列表项
【发布时间】:2019-11-06 20:43:52
【问题描述】:

尝试在 SharePoint 列表中实现水平平铺/按钮视图,以使用关联的列表属性 webpart,但是项目选择不起作用,如果可能,请在 JSON 中寻找解决方法。

我尝试寻找可以以相同方式工作的 customRowAction 设置,但一无所获。 "hideSelection": "true",似乎完全关闭了选择项目的能力。

我希望能够单击列表项并将其重新注册为“选定”项以触发关联的列表属性 webpart 以显示项内容。 OOTB 此功能按预期运行,但与 JSON 中显示的列表视图样式不同。

{
  "schema": "https://developer.microsoft.com/json-schemas/sp/view-formatting.schema.json",
  "hideSelection": "true",
  "hideColumnHeader": "true",
  "rowFormatter": {
    "elmType": "div",
    "style": {
      "float": "left"
    },
    "children": [
      {
        "elmType": "button",
        "customRowAction": {
          "action": "defaultClick"
        },
        "attributes": {
          "class": "ms-bgColor-themeLighterAlt ms-bgColor-themePrimary--hover ms-fontColor-white--hover"
        },
        "style": {
          "display": "flex",
          "flex-wrap": "wrap",
          "min-width": "150px",
          "min-height": "50px",
          "margin-right": "10px",
          "margin-top": "10px",
          "box-shadow": "2px 2px 4px darkgrey"
        },
        "children": [
          {
            "elmType": "div",
            "style": {
              "text-align": "center",
              "margin": "auto"
            },
            "children": [
              {
                "elmType": "div",
                "attributes": {
                  "class": "sp-row-title "
                },
                "txtContent": "[$Phase]"
              }
            ]
          }
        ]
      }
    ]
  }
}

【问题讨论】:

    标签: json listview sharepoint-online web-parts


    【解决方案1】:

    如果要在 List Properties Web 部件中显示项目,则需要使用默认的列表视图样式,如果使用 JSON 格式自定义列表视图,它将不起作用。

    使用您的 JSON 格式,当我们单击按钮时,我们可以在同一页面的面板中看到项目数据。为什么要在列表属性 web 部件中显示?

    【讨论】:

    • 我们希望使用列表属性 webpart 在同一现代页面中提供其他上下文信息,不仅是列表内容,我们还希望将聚合内容堆叠在水平按钮下方。
    • 作为一种解决方法,我们可以使用 jQuery 来监视按钮单击事件,然后使用 REST API 获取列表项并在按钮下方显示数据,将自定义代码添加到现代脚本编辑器 Web 部件中。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-02-10
    • 1970-01-01
    相关资源
    最近更新 更多