my sharepoint list has multiple multi line columns. however they wanted the text to wrap to not show inconsistent column heights.
What I have tried:
i tried adding CEWP but nothing works. i saw this code over the net but nothing works.
var DC = DC || {};
DC.multilineOverride = (function () {
function renderLessAndMoreDivs(ctx) {
var summaryLength = 75;
var fullText = ctx.CurrentItem[ctx.CurrentFieldSchema.Name];
if (fullText.length < summaryLength) {
return "
" + fullText + "
";
}
var shortText = fullText.slice(0, summaryLength) + "...";
var fullTextDivId = ctx.CurrentFieldSchema.Name + "_" + ctx.CurrentItem.ID +
"_FullText";
var shortTextDivId = ctx.CurrentFieldSchema.Name + "_" + ctx.CurrentItem.ID +
"_ShortText";
var fullTextDiv = "
";
var shortTextDiv = "
";
var returnHtml = "
" + fullTextDiv + shortTextDiv + "
";
return returnHtml;
}
function buildShowHideJS(idToHide, idToShow) {
var jsString = "document.getElementById(\"" + idToHide + "\").setAttribute
(\"style\", \"display:none\");";
jsString += "document.getElementById(\"" + idToShow + "\").setAttribute(\"style
\", \"display:block\");";
jsString += "return false;";
return jsString;
}
return {
render: function () {
SPClientTemplates.TemplateManager.RegisterTemplateOverrides({
Templates: {
Fields: {
"MultilineTextField_1": {
View: renderLessAndMoreDivs,
},
"MultilineTextField_2": {
View: renderLessAndMoreDivs,
}
},
},
});
}
}
})();
RegisterModuleInit(SPClientTemplates.Utility.ReplaceUrlTokens
("~site/SiteAssets/Scripts/MultiLineShowMoreLess.js"), DC.multilineOverride.render);
DC.multilineOverride.render();