1

I am using JSON to format the height and width of my columns in a SharePoint list.

Some of these columns are set to be hyperlinks or advanced rich text. When I apply the JSON formatting, it takes the hyperlinks out and makes them the full URL. Is there any way to fix this? Here is the JSON I am using for the height and width:

{
  "$schema": "https://developer.microsoft.com/json-schemas/sp/v2/column-formatting.schema.json",
  "elmType": "div",
  "txtContent": "@currentField",
  "style": {
    "min-height": "1em",
    "height": "11em",
    "width": "300px"
  }
} 

1 Answer 1

0

For hyperlink columns, you can use JSON like below to keep the hyperlink URL and description as is in default SharePoint list view:

{
  "$schema": "https://developer.microsoft.com/json-schemas/sp/v2/column-formatting.schema.json",
  "elmType": "a",
  "txtContent": "@currentField.desc",
  "attributes": {
    "href": "@currentField",
    "target": "_blank"
  },
  "style": {
    "min-height": "1em",
    "height": "11em",
    "width": "300px"
  }
}

You can apply other styling like color, background color, etc. as per your requirements.

List view - before formatting:

enter image description here

List view - after formatting:

enter image description here

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.