0

I have a library that uses Document Sets and there are columns on the document set content type.

I want to display them in a view that uses the Tile format like this:

enter image description here

I use the JSON column formatting for the columns, but it does not appear to use the formatters in the Tiles. Is there any way to customize the view of them in the tiles?

I've tried added the formatter in the Content Type it uses and using Format Current View but they always display in the tiles without the formatting.

1
  • Did you try using columnFormatterReference to refer the column formatting in view formatting JSON? You have to pass the internal name of column to this property. Let me know if this works for you or if you need any further help. Commented Aug 24, 2023 at 6:41

1 Answer 1

1

You can refer the JSON column formatting for the columns in Tiles view using columnFormatterReference.

You will have to open the Tile/Gallery view JSON in advanced mode and make the changes accordingly.

For example:

Here is the JSON I used for DocSetColumn in the document library:

{
  "$schema": "https://developer.microsoft.com/json-schemas/sp/v2/column-formatting.schema.json",
  "elmType": "div",
  "style": {
    "color": "red"
  },
  "txtContent": "@currentField"
}

Output:

enter image description here

Here is the JSON I used for Tile/Gallery view in the document library:

{
  "$schema": "https://developer.microsoft.com/json-schemas/sp/v2/tile-formatting.schema.json",
  "height": 323,
  "width": 254,
  "hideSelection": false,
  "fillHorizontally": true,
  "formatter": {
    "elmType": "div",
    "attributes": {
      "class": "sp-card-container"
    },
    "children": [
      {
        "elmType": "div",
        "attributes": {
          "class": "sp-card-defaultClickButton"
        },
        "customRowAction": {
          "action": "defaultClick"
        }
      },
      {
        "elmType": "div",
        "attributes": {
          "class": "ms-bgColor-white sp-css-borderColor-neutralLight sp-card-borderHighlight sp-card-subContainer"
        },
        "children": [
          {
            "elmType": "div",
            "attributes": {
              "class": "sp-card-previewColumnContainer"
            },
            "children": [
              {
                "elmType": "div",
                "attributes": {
                  "class": "sp-card-imageContainer"
                },
                "children": [
                  {
                    "elmType": "filepreview",
                    "attributes": {
                      "src": "@thumbnail.512x432"
                    },
                    "style": {
                      "height": "200px"
                    },
                    "filePreviewProps": {
                      "fileTypeIconClass": "sp-fileTypeIcon-cardDesigner",
                      "brandTypeIconClass": "sp-brandTypeIcon-cardDesigner"
                    }
                  }
                ]
              }
            ]
          },
          {
            "elmType": "div",
            "attributes": {
              "class": "sp-card-displayColumnContainer"
            },
            "children": [
              {
                "elmType": "p",
                "attributes": {
                  "class": "ms-fontColor-neutralSecondary sp-card-label"
                },
                "txtContent": "[!FileLeafRef.DisplayName]"
              },
              {
                "elmType": "p",
                "attributes": {
                  "class": "ms-fontColor-neutralPrimary sp-card-content sp-card-highlightedContent sp-card-keyboard-focusable"
                },
                "txtContent": "[$FileLeafRef]",
                "defaultHoverField": "[$FileLeafRef]"
              }
            ]
          },
          {
            "elmType": "div",
            "attributes": {
              "class": "sp-card-lastTextColumnContainer"
            },
            "children": [
              {
                "elmType": "p",
                "attributes": {
                  "class": "ms-fontColor-neutralSecondary sp-card-label"
                },
                "txtContent": "[!DocSetColumn.DisplayName]"
              },
              {
                "columnFormatterReference": "[$DocSetColumn]"
              }
            ]
          }
        ]
      }
    ]
  }
}

Note: You have to pass the internal name of your column to columnFormatterReference property. You can get the internal name of your column by following this article: How to find the Internal name of columns in SharePoint Online?

Output:

enter image description here

Your Answer

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

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