SharePoint List Formatting - Card Preview pointing to URL #8494
Unanswered
marcosjfcf
asked this question in
Q&A
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Hi everyone.
I recently started to use JSON for formatting lists, I'm still in learning process.
I found out a card preview used for files... I was wondering if I could do that point to other column of the list and preview a document using its hyperlink ?
{
"$schema": "https://developer.microsoft.com/json-schemas/sp/v2/column-formatting.schema.json",
"elmType": "div",
"children": [
{
"elmType": "div",
"style": {
"border-radius": "50%",
"cursor": "pointer",
"font-size": "15px",
"width": "27px",
"height": "27px",
"display": "flex",
"justify-content": "center",
"align-items": "center",
"font-weight": "bold"
},
"attributes": {
"class": "ms-bgColor-themeLighter ms-bgColor-themePrimary--hover ms-fontColor-neutralPrimary ms-fontColor-white--hover",
"iconName": "View"
},
"customCardProps": {
"openOnEvent": "click",
"directionalHint": "rightCenter",
"isBeakVisible": true,
"formatter": {
"elmType": "filepreview",
"attributes": {
"src": "=if([$File_x0020_Type] == '' || [$File_x0020_Type] == 'aspx' || [$File_x0020_Type] == 'pdf', [$FileRef] , if([$File_x0020_Type] == 'docx' || [$File_x0020_Type] == 'dotx' || [$File_x0020_Type] == 'dotm' || [$File_x0020_Type] == 'docm' || [$File_x0020_Type] == 'docb' || [$File_x0020_Type] == 'pptx' || [$File_x0020_Type] == 'pptm' || [$File_x0020_Type] == 'potx' || [$File_x0020_Type] == 'potm' || [$File_x0020_Type] == 'ppam' || [$File_x0020_Type] == 'ppsx' || [$File_x0020_Type] == 'ppsm' || [$File_x0020_Type] == 'sldx' || [$File_x0020_Type] == 'sldm' || [$File_x0020_Type] == 'vsdx' || [$File_x0020_Type] == 'xlsx' || [$File_x0020_Type] == 'xlsm' || [$File_x0020_Type] == 'xltx' || [$File_x0020_Type] == 'xltm', @currentWeb +'/_layouts/15/WopiFrame.aspx?sourcedoc=' + [$FileRef] + '&action=view' , @currentWeb +'/_layouts/15/embed.aspx?UniqueId=' + [$UniqueId] + '&client_id=FileViewerWebPart&showNewWindow=true&embed={"af":false,"p":1,"z":"width"}&auth=readwrite'))"
},
"style": {
"width": "= @window.innerWidth * 0.5 + 'px'",
"height": "= @window.innerHeight * 0.8 + 'px'"
},
"filePreviewProps": {
"brandTypeIconStyle": {
"display": "none"
}
}
}
}
}
]
}
Can I use this sample (Source: https://github.com/tecchan1107/sp-dev-list-formatting/tree/generic-card-page-view/column-samples/generic-file-view-card) but change the attribute to other column on the list ? For instance: ""href": "[$ColumnX]"
I'm looking for the same result but using the document hyperlink instead of the file.
Beta Was this translation helpful? Give feedback.
All reactions