hope you're well;
What is javaScript code to add on SharePoint list for showing a few lines of text per row so they all the same size where reams of text have been written this is via scroll or expand arrow can it be applied to all views.
SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. It only takes a minute to sign up.
Sign up to join this communityYou could probably use JSLink and create a substring of the text in that field.
As an example this is what i'm using to modify list view fields before they are loaded (a simple STATUS color based on what is selected).
var statusFieldCtx = {};
statusFieldCtx.Templates = {};
statusFieldCtx.Templates.Fields = {
"Status": {
"View": StatusFieldViewTemplate
}
};
SPClientTemplates.TemplateManager.RegisterTemplateOverrides(
statusFieldCtx
);
And then i'm using something like this to append values.
function StatusFieldViewTemplate(ctx) {
var _statusValue = ctx.CurrentItem.Status;
if (_statusValue == "New") {
return "<span class='statusSpanJS' style = 'background-color: #BDD7EE; padding: 5px 0px 8px 5px; display: block; height: 100%; width:100%;'>" + _statusValue + "</span>";
}
Based on that code you could get the field that you need to trim and use substring.
You can read more -> https://www.c-sharpcorner.com/article/modify-sharepoint-list-view-using-client-side-rendering-and-jslink/
https://www.w3schools.com/jsref/jsref_substring.asp
By using substring you would simply limit the appended value to like 100 (therefore all of the items will be of equal length/size).