Forum Discussion
tiredoldcoder
Mar 22, 2019Copper Contributor
Unable to format document library Title field with JSON
I can set the JSON for the title field, Preview works, Save works, but as soon as I Cancel the formatting pane, the formatting disappears. Re-opening the formatting pane shows no contents. It appea...
- Mar 25, 2019
Hello tiredoldcoder ,
I don't believe the Name/Title column is supported.
From Use column formatting to customize SharePoint:
Supported column types
The following column types support column formatting:
- Single line of text
- Number
- Choice
- Person or Group
- Yes/No
- Hyperlink
- Picture
- Date/Time
- Lookup
- Title (in Lists)
The following are not currently supported:
- Managed Metadata
- Filename (in Document Libraries)
- Calculated
- Retention Label
- Currency
I hope this helps.
Norm
tonyknibb
Oct 04, 2019Copper Contributor
tiredoldcoder I think this is a bug in the interface. I've had my formatting vanish after closing the formatting pane. On refreshing the page my formatting comes back and is now available to edit again.
It gets even more interesting if you're working on a List with multiple formatted views...
This is how I'm formatting my Document Library:
{
"schema": "<a href="https://developer.microsoft.com/json-schemas/sp/view-formatting.schema.json" target="_blank">https://developer.microsoft.com/json-schemas/sp/view-formatting.schema.json</a>",
"hideSelection": true,
"hideColumnHeader": true,
"rowFormatter": {
"elmType": "a",
"attributes": {
"href": "[$FileRef]",
"title": "[$FileLeafRef]",
"target": "=if([$NewTab] == true, '_blank', '')",
"class": "ms-bgColor-themePrimary ms-bgColor-themeDark--hover ms-fontColor-neutralLighterAlt"
},
"style": {
"float": "left",
"position": "relative",
"text-decoration": "none",
"width": "100%",
"margin-top": "5px"
},
"children": [
{
"elmType": "div",
"attributes": {},
"style": {
"display": "flex",
"min-width": "100%",
"min-height": "40px",
"-webkit-font-smoothing": "antialiased",
"font-size": "14px",
"font-weight": "400",
"box-sizing": "border-box",
"cursor": "pointer",
"user-select": "none",
"outline": "transparent",
"border-width": "1px",
"border-style": "solid",
"border-color": "transparent",
"border-image": "initial",
"text-decoration": "none",
"border-radius": "0px"
},
"children": [
{
"elmType": "div",
"style": {
"text-align": "left",
"display": "flex",
"min-width": "60%",
"min-height": "40px",
"box-sizing": "border-box",
"align-items": "center"
},
"children": [
{
"elmType": "div",
"attributes": {
"iconName": "=if([$File_x0020_Type] == 'docx', 'wordDocument', if([$File_x0020_Type] == 'xlsx', 'ExcelDocument', if([$File_x0020_Type] == 'pptx', 'PowerPointDocument', if([$File_x0020_Type] == 'pdf', 'PDF', if([$File_x0020_Type] == 'jpg' || [$File_x0020_Type] == 'png' || [$File_x0020_Type] == 'gif', 'FileImage', if([$File_x0020_Type] == 'mp4' || [$File_x0020_Type] == 'avi' || [$File_x0020_Type] == 'mov', 'MSNVideos', if([$File_x0020_Type] == 'zip', 'ZipFolder','Unknown')))))))"
},
"style": {
"flex": "none",
"line-height": "100%",
"font-weight": "normal",
"font-size": "2rem",
"margin": "5px 5px 5px 10px"
}
},
{
"elmType": "div",
"style": {
"flex": "none",
"line-height": "100%",
"font-weight": "600",
"margin": "5px 5px 5px 10px"
},
"txtContent": "=if([$Title] == '', '[$FileLeafRef]', '[$Title]')"
}
]
},
{
"elmType": "div",
"attributes": {
"class": "ms-bgColor-white"
},
"style": {
"flex": "none",
"text-align": "left",
"box-sizing": "border-box",
"align-items": "center",
"display": "=if([$Description] == '', 'none', 'flex')",
"min-width": "40%",
"min-height": "40px"
},
"children": [
{
"elmType": "div",
"attributes": {
"class": "ms-fontColor-black"
},
"style": {
"width": "100%",
"line-height": "100%",
"font-weight": "600",
"font-size": "11px",
"margin": "5px"
},
"txtContent": "[$Description]"
}
]
}
]
}
]
}
}T.