Click here to Skip to main content
15,887,596 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
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 = "
" +

fullText + "
Show less
";
var shortTextDiv = "
" + shortText + "


href='#' >Show

more
";
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();
Posted

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900