Disallow switching to list from tile view, OR apply JSON formatting to both options.

Arnaud H 0 Reputation points
2025-04-09T13:41:43.08+00:00

Hi,

I have some JSON formatting applied to my tile view library in Sharepoint to spice it up a bit on company level. Everything is pretty well locked down, however users can still ignore the JSON formatting by simply going from tile view to list view. I recall having an option below "format view" to change from "gallery" to "list", but this seems to be missing for me at the moment...
User's image

This is my code:

Any ideas what i can do to limit users to see the formatted view, or to also apply formatting to list view as well? Thanks in advance...

{
  "$schema": "https://developer.microsoft.com/json-schemas/sp/v2/tile-formatting.schema.json",
  "commandBarProps": {
    "commands": [
      { "key": "automate", "hide": true },
      { "key": "delete", "hide": true },
      { "key": "open", "hide": true },
      { "key": "Favorite", "hide": true },
      { "key": "moveTo", "hide": true },
      { "key": "copyTo", "hide": true },
      { "key": "rename", "hide": true },
      { "key": "versionHistory", "hide": true },
      { "key": "checkOut", "hide": true },
      { "key": "properties", "hide": true, "sectionType": "Primary" },
      { "key": "download", "hide": true },
      { "key": "copyLink", "hide": true },
      { "key": "share", "hide": true },
      { "key": "newComposite", "hide": true, "sectionType": "Overflow" },
      { "key": "exportExcel", "hide": true },
      { "key": "integrate", "hide": true },
      { "key": "PinToQuickAccessCommand", "hide": true },
      { "key": "pinToQuickAccess", "hide": true },
      { "key": "addShortcutToOneDriveCommand", "hide": false },
      { "key": "addShortcut", "hide": false },
      { "key": "export", "hide": true },
      { "key": "uploadTemplate", "hide": true },
      { "key": "uploadFile", "hide": true },
      { "key": "uploadFolder", "hide": true },
      { "key": "upload", "hide": true },
      { "key": "UploadCommand", "hide": true, "sectionType": "Overflow" },
      { "key": "alertMe", "hide": true },
      { "key": "manageAlert", "hide": true },
      { "key": "syncCommand", "hide": true },
      { "key": "sync", "hide": true },
      { "key": "new", "hide": true }
    ]
  },
  "hideSelection": true,
  "fillHorizontally": true,
  "height": 250,
  "formatter": {
    "elmType": "div",
    "attributes": {
      "class": "sp-card-container"
    },
    "children": [
      {
        "elmType": "div",
        "attributes": {
          "class": "ms-bgColor-white sp-css-borderColor-neutralLight sp-card-borderHighlight sp-card-subContainer"
        },
        "customRowAction": {
          "action": "defaultClick"
        },
        "style": {
          "cursor": "pointer",
          "background-color": "=if(indexOf([$FileRef], 'Obsolete') > -1, '#2f2c2a', 'white')"
        },
        "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-lastTextColumnContainer"
            },
            "children": [
              {
                "elmType": "p",
                "attributes": {
                  "class": "ms-fontColor-neutralPrimary sp-card-content sp-card-highlightedContent sp-card-keyboard-focusable"
                },
                "style": {
                  "color": "=if(indexOf([$FileRef], 'Obsolete') > -1, 'white', 'black')"
                },
                "txtContent": "[$FileLeafRef]",
                "defaultHoverField": "[$FileLeafRef]"
              }
            ]
          }
        ]
      },
      {
        "elmType": "a",
        "txtContent": "Contact the team ᯓ➤",
        "style": {
          "font-size": "15px",
          "font-family": "Segoe UI, Tahoma, Arial, sans-serif",
          "padding": "0px 16px",
          "border-radius": "4px",
          "color": "white",
          "background-color": "#e73b2b",
          "text-align": "center",
          "display": "inline-block",
          "text-decoration": "none",
          "position": "fixed",
          "top": "90%",
          "left": "45%",
          "z-index": "9999",
          "cursor": "pointer",
          "box-shadow": "1px 1px 2px rgba(200, 200, 200, 1)",
          "transition": "background-color 0.3s, transform 0.2s",
          "border": "none"
        },
        "attributes": {
          "href": "https://www.google.com",
          "target": "_blank"
        }
      }
    ]
  }
}
SharePoint Development
SharePoint Development
SharePoint: A group of Microsoft Products and technologies used for sharing and managing content, knowledge, and applications.Development: The process of researching, productizing, and refining new or existing technologies.
3,574 questions
0 comments No comments
{count} votes

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.