SharePoint list column header multi line

"Yes" to the limiting to a certain number of lines of text, but "No" to the "see more" button, at least within the capabilities of JSON Formatting.

You can limit the number of lines display with an ellipses ["..."] by adding line-clamp CSS styles to your div. Note the value of -webkit-line-clamp is the number of lines you want to display.

{ "$schema": "//developer.microsoft.com/json-schemas/sp/v2/column-formatting.schema.json", "elmType": "div", "style": { "display": "-webkit-box", "-webkit-line-clamp": 3, "-webkit-box-orient": "vertical", "overflow": "hidden" }, "txtContent": "@currentField" }

However, you cannot embed JavaScript in a JSON column formatter, so if you want a "see more" button that can toggle display the rest of the text, you will need to build a custom-coded SharePoint Framework [SPFx] Field Extension.

You can apply column formatting to customize the display of fields in Modern SharePoint lists and libraries view by using JSON. The column formatting does not change the actual data in the list item or file, it only changes how the value is displayed to users in the user interface.


⛔️ Longer values truncated in SharePoint Modern List View experience

SharePoint List view - column value truncated


  1. Navigate to your modern SharePoint list view.
  2. Click on the column name.
  3. Click Column Settings.
  4. Click Format this column.
  5. SharePoint Online Modern experience - format column

  6. A pane will open from right side of screen with title 'Format [Column Name] column'. Make sure 'Format columns' tab is selected and your column is selected in Choose Column drop down.
  7. Scroll to bottom and click Advanced mode.
  8. Copy and paste this JSON in the text box "Paste or type your column-formatting JSON here."
  9. { "$schema": "//developer.microsoft.com/json-schemas/sp/column-formatting.schema.json", "elmType": "div", "style":{ "white-space":"wrap" }, "txtContent": "@currentField" }

    CSS style for wrapping text --> "white-space":"wrap"

    SharePoint - format column advanced mode

  10. Click Preview to check the display changes and make adjustments.
  11. Once comfortable, click Save.
  12. The changes will be reflected on the view.
  13. You can use similar JSON approach for formatting other column values.

SharePoint column format - wrap text using json

⭐ Note that the JSON formatting changes only the display of column values on the UI. The column headers cannot be controlled and wrapped.

⭐ The JSON formatting changes apply to Grid View editing as well.

Comments:

More Posts related to SharePoint,

More Posts:

SharePoint Diary » PowerShell » SharePoint Online: Add Multiple Lines of Text Column to List using PowerShell

The Multiple Lines of Text column in SharePoint Online is used to store multiple rows of text value. Based on the field settings, it can contain Rich text, including text, images, HTML formatted values, etc.

To add multiple lines of text field to a list in SharePoint Online, follow these steps:

  • Browse to your SharePoint Online site and Navigate to the target list in which you want to add Choice column.
  • Under the List tab, click on “Create Column” button in the ribbon.
  • Provide the Name to your new column, specify the type as “Multiple lines of text”
  • Fill other optional values such as Number of lines, Type of text, append changes to existing text, etc. and Click on “OK” to create Multiple lines of text column in SharePoint Online list.

PowerShell to Create Multiple Lines of Text Column in SharePoint Online List:

#Load SharePoint CSOM Assemblies Add-Type -Path "C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\16\ISAPI\Microsoft.SharePoint.Client.dll" Add-Type -Path "C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\16\ISAPI\Microsoft.SharePoint.Client.Runtime.dll" #Custom function to add column to list Function Add-MultilineTextColumnToList[] { param [ [Parameter[Mandatory=$true]] [string] $SiteURL, [Parameter[Mandatory=$true]] [string] $ListName, [Parameter[Mandatory=$true]] [string] $Name, [Parameter[Mandatory=$true]] [string] $DisplayName, [Parameter[Mandatory=$false]] [string] $Description=[string]::Empty, [Parameter[Mandatory=$false]] [string] $IsRequired = "FALSE", [Parameter[Mandatory=$false]] [string] $IsRichText="FALSE", [Parameter[Mandatory=$false]] [string] $NumLines = "6", [Parameter[Mandatory=$false]] [string] $EnhancedRichText = "FALSE" ] #Generate new GUID for Field ID $FieldID = New-Guid Try { $Cred= Get-Credential $Credentials = New-Object Microsoft.SharePoint.Client.SharePointOnlineCredentials[$Cred.Username, $Cred.Password] #Setup the context $Ctx = New-Object Microsoft.SharePoint.Client.ClientContext[$SiteURL] $Ctx.Credentials = $Credentials #Get the List $List = $Ctx.Web.Lists.GetByTitle[$ListName] $Ctx.Load[$List] $Ctx.ExecuteQuery[] #Check if the column exists in list already $Fields = $List.Fields $Ctx.Load[$Fields] $Ctx.executeQuery[] $NewField = $Fields | where { [$_.Internalname -eq $Name] -or [$_.Title -eq $DisplayName] } if[$NewField -ne $NULL] { Write-host "Column $Name already exists in the List!" -f Yellow } else { #Define XML for Field Schema if[$EnhancedRichText -eq "TRUE"] #Enhanced Rich Text Mode { $FieldSchema = "" } else #Plain Text or Rich Text { $FieldSchema = "" } $NewField = $List.Fields.AddFieldAsXml[$FieldSchema,$True,[Microsoft.SharePoint.Client.AddFieldOptions]::AddFieldInternalNameHint] $Ctx.ExecuteQuery[] Write-host "New Column Added to the List Successfully!" -ForegroundColor Green } } Catch { write-host -f Red "Error Adding Column to List!" $_.Exception.Message } } #Set parameter values $SiteURL="//crescent.sharepoint.com" $ListName="Projects" $Name="ProjectDescription" $DisplayName="Project Description" $Description="Enter the Project Description" $IsRichText="FALSE" #FALSE for Plain text / TRUE for Rich text $EnhancedRichText="FALSE" #FALSE for Rich text / TRUE for Enhanced Rich Text, Takes Precedence over IsRichText parameter value #Call the function to add column to list Add-MultilineTextColumnToList -SiteURL $SiteURL -ListName $ListName -Name $Name -DisplayName $DisplayName -Description $Description -IsRichText $IsRichText -EnhancedRichText $EnhancedRichText

#Config Variables $SiteURL = "//Crescent.sharepoint.com/sites/marketing" $ListName= "Projects" #Connect to PnP Online Connect-PnPOnline -Url $SiteURL -Credentials [Get-Credential] #Add Multiple lines of Text Field to list Add-PnPField -Type Note -List $ListName -DisplayName "Project Description" -InternalName "ProjectDescription" -AddToDefaultView

Similarly, you can add a multi-line text field to SharePoint Online List from the XML schema.

#Define XML Schema for Multiline Text Field $FieldXML= "" #Add Choice Field to list from XML Add-PnPFieldFromXml -FieldXml $FieldXML -List $ListName

Related Posts

Salaudeen Rajack – SharePoint Architect. Primarily on Infrastructure, Operations, Administration and Architecture!

Want to contribute?
Are you a SharePoint expert? Well, You can start contributing to this site! Find out now: How to Contribute and What you’ll get in return?

Video liên quan

Chủ Đề