SharePoint developers can use JSON to format columns, views and customize list form.
Let us look at an example to preview the file content using a hover card, when the user moves the mouse over the file name (or any other field of your choice).
We are going to setup a new column "preview" (single line of text) and apply JSON formatting to this column.
- Navigate to your list/library.
- Select the column in view.
- Click Column settings --> Format this column.
- This will open a pane in the right section of screen 'Format preview column'.
- Copy and paste below JSON in the text box.
- Click Preview and make adjustments, if required.
- Click 'Save' once comfortable with the hover card.
SharePoint JSON column formatting
{
"$schema": "https://developer.microsoft.com/json-schemas/sp/column-formatting.schema.json",
"elmType": "img",
"attributes": {
"src": "@thumbnail.medium"
},
"style": {
"display": "block",
"margin": "0 auto",
"max-height": "100px"
},
"customCardProps": {
"openOnEvent": "hover",
"isBeakVisible": true,
"formatter": {
"elmType": "img",
"attributes": {
"src": "@thumbnail.200x400"
},
"style": {
"max-height": "400px"
}
}
}
}
This is how the output will look. When user moves mouse and hover over the 'preview' column value of the file in Document Library, the hover card will popup and shows the contents of the file. You can adjust the height/width and other style parameters for the card.
Also note that we are showing a small thumbnail preview of the file in the same 'preview' column.
SharePoint file hover preview using JSON
Have Questions? Post them here!
More Posts related to SharePoint,
- Managed Metadata error - The data returned from the tagging UI was not formatted correctly
- How to generate client id and secret to register SharePoint App with OAuth
- Create SharePoint Site Collection with new Content database in existing web application
- Fix Error 2711 SQL RBS client - The installer has encountered an unexpected error. The specified Feature name ('Docs') not found in Feature table
- How to exclude results from SharePoint Search
- 'Edit Document' Requires a Windows Sharepoint Services-compatible application and Microsoft Internet Explorer 6.0 or higher
- [Solved] SharePoint Access Denied error editing Document Name
- Recommended size and resolution for SharePoint Online Site logo
- SharePoint Server 2016 IT Preview - new improved Features and Enhancements
- Restore deleted Office 365 SharePoint group site
- SharePoint An unexpected error has occurred - Correlation ID and PowerShell Merge-SPlogfile
- [Solved] SharePoint Search Internal server error exception
- SharePoint CAML query error - The XML source is not correct
- How to hide quick launch in SharePoint classic site
- Not receiving email notification alert in SharePoint Online workflow - Power Automate, FLOW
- Change SharePoint search results FullTextSqlQuery RowLimit 10000
- Fix Power BI error Access to the resource is forbidden when connecting SharePoint Online List as data source
- [Fix] Restricted View permission level missing in SharePoint Online site library
- How to upload file programmatically to SharePoint Document Library using Server Object Model C# .Net
- How to create classic site in SharePoint Online
- That did'nt work, Issue type User not in directory - SharePoint external access error
- Merge-SPlogfile PowerShell - SharePoint Correlation ID error
- Fix Power BI 404 not found error when connecting SharePoint Online List as Data Source
- SharePoint Server 2016 IT Preview Deprecated Removed features
- SharePoint error - An exception occurred when trying to issue security token: This implementation is not part of the Windows Platform FIPS validated cryptographic algorithms..
More Posts:
- Difference between using Scanner Class and String args for user input in Java - Java
- New-SPLogFile PowerShell - create new SharePoint log file - SharePoint
- Maven : java.lang.ClassNotFoundException: Xmx512m - Android
- Find Difference of two numbers - C-Program
- How to take user input from the console in a Python program - Python
- How to start or open a new bourne-again shell (bash) session on Windows using Command Line CMD - Bash
- How to Import External Jars to Android Studio Project - Android-Studio
- Exception in thread main java.lang.NoClassDefFoundError: package javaClass - Java