Formatierung der JSON-Spaltenformatierung

Aug 21 2020

Ich erstelle eine benutzerdefinierte Formatierung für die Titelspalte einer Dokumentbibliothek, damit Benutzer die Dokumente immer herunterladen, anstatt sie direkt zu öffnen.

Es läuft gut, aber ich kann mir kein Styling-Detail vorstellen: Ich möchte, dass der Link beim Schweben unterstrichen wird.

so im Pseudoformatierungscode : style:hover{ text-decoration: underline; }. Der Link selbst ist bereits wie unten gezeigt gestaltet

{
  "$schema": "http://columnformatting.sharepointpnp.com/columnFormattingSchema.json",
  "elmType": "a",
  "txtContent": "@currentField",
  "style": {
    "color": "#272727",
    "text-decoration": "none",
    "font-size": "14px"
  },
  "attributes": {
    "target": "_blank",
    "href": {
      "operator": "+",
      "operands": [
        "http://tenant.sharepoint.com/sitename/_layouts/download.aspx?SourceUrl=http://tenant.sharepoint.com/sitename/Library/",
        "@currentField"
      ]
    }
  }
}

Antworten

2 theChrisKent Aug 21 2020 at 14:34

Ich habe lange nach Schwebestilen gefragt. Wie Michael Han_MSFT in seiner Antwort schrieb, ist das Beste, was Sie bekommen können, leider der --hoverUnterricht.

Glücklicherweise können Sie mit ihnen kreativ werden, um das zu erreichen, was Sie wollen. Probieren Sie dieses Format aus:

{
  "$schema": "http://columnformatting.sharepointpnp.com/columnFormattingSchema.json",
  "elmType": "div",
  "children": [
    {
      "elmType": "a",
      "txtContent": "@currentField",
      "style": {
        "color": "#272727",
        "text-decoration": "none",
        "font-size": "14px",
        "display": "inline-block",
        "border-bottom-width": "1px",
        "border-bottom-style": "solid"
      },
      "attributes": {
        "target": "_blank",
        "class": "ms-borderColor-white ms-borderColor-themePrimary--hover",
        "href": {
          "operator": "+",
          "operands": [
            "http://tenant.sharepoint.com/sitename/_layouts/download.aspx?SourceUrl=http://tenant.sharepoint.com/sitename/Library/",
            "@currentField"
          ]
        }
      }
    }
  ]
}

Hier ist es in Aktion:

MichaelHan_MSFT Aug 21 2020 at 09:33

Sie können ms-bgColor-<color>--hoverden Schwebestil ändern.

{
  "$schema": "http://columnformatting.sharepointpnp.com/columnFormattingSchema.json",
  "elmType": "a",
  "txtContent": "@currentField",

  "style": {
    "color": "#272727",
    "text-decoration": "none",
    "font-size": "14px"
  },
  "attributes": {
    "target": "_blank",
    "class": "ms-bgColor-red--hover",
    "href": {
      "operator": "+",
      "operands": [
        "http://tenant.sharepoint.com/sitename/_layouts/download.aspx?SourceUrl=http://tenant.sharepoint.com/sitename/Library/",
        "@currentField"
      ]
    }
  }
}