Oct 03 2019 04:51 AM - edited Oct 03 2019 04:54 AM
Hi,
Im create a view in a document library to give an overview of the files with a description.
On that view I would like a download button, to download the files directly.
On known file formats link JPG i just opens the file and on unknown formats link EPS it dowloads the file.
The code looks like this:
"elmType": "button",
"style": {
"background-color": "#6eb556",
"color": "white",
"font-weight": "bold",
"font-size": "1rem",
"float": "right",
"margin-right": "150px"
},
"customRowAction": {
"action": "Download"
},
"txtContent": "Download",
"attributes": {
"class": "sp-row-button"
Is there a way to force it always to download the file?
Oct 23 2020 03:02 AM
@Jesper Würtz Have you found a solution to this? I also need a button in a sharepoint document library that allows the user to download documents.
According to this article it seems that only
are valid option for "customRowAction.
Jan 03 2022 05:13 AM
I have a script for a download button that works:
{
"$schema": "https://developer.microsoft.com/json-schemas/sp/column-formatting.schema.json",
"elmType": "button",
"style": {
"flex-direction": "column",
"width": "80px",
"border": "none",
"border-radius": "3px",
"margin": "10px 0"
},
"attributes": {
"class": "ms-bgColor-themePrimary"
},
"children": [
{
"elmType": "a",
"txtContent": "Download",
"style": {
"color": "white",
"text-decoration": "none",
"padding": "12px 0px 12px 0px"
},
"attributes": {
"target": "_blank",
"href": "= @currentWeb + '/_layouts/15/download.aspx?UniqueId=' + [$UniqueId]"
}
}
]
}
How to:
Screenshot: