Forum Discussion
Jesper Würtz
Oct 03, 2019Copper Contributor
Download button in View formatting JSON
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?
2 Replies
Sort By
- nina_torjesenCopper Contributor
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:
- Create a single line column named f.ex. "Download"
- Add the json script in format column
Screenshot:
- nina_torjesenCopper Contributor
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
- defaultClick
- share
- delete
- editProps
- executeFlow
are valid option for "customRowAction.