Форматирование столбцов JSON при наведении курсора

Aug 21 2020

Я создаю настраиваемое форматирование для столбца заголовка библиотеки документов, чтобы пользователи всегда загружали документы, а не открывали их напрямую.

Получается хорошо, но я не могу понять одну деталь стиля: я хочу, чтобы ссылка подчеркивалась при наведении курсора.

так в псевдо форматирования код style:hover{ text-decoration: underline; }. Сама ссылка уже оформлена, как показано ниже.

{
  "$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"
      ]
    }
  }
}

Ответы

2 theChrisKent Aug 21 2020 at 14:34

Я давно прошу стили наведения. К сожалению, как написал Майкл Han_MSFT в своем ответе, лучшее, что вы можете получить, - это --hoverклассы.

К счастью, вы можете проявить творческий подход к ним, чтобы добиться желаемого. Попробуйте этот формат:

{
  "$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"
          ]
        }
      }
    }
  ]
}

Вот он в действии:

MichaelHan_MSFT Aug 21 2020 at 09:33

Вы можете использовать ms-bgColor-<color>--hoverдля изменения стиля наведения.

{
  "$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"
      ]
    }
  }
}