I am working on a Sharepoint display template that involves manipulating an array of objects to achieve a specific output.
Name1
Name2
Name3
My goal is to customize the rendering of multiple people user field in Sharepoint by implementing a tooltip feature.
However, I am facing a challenge with iterating through the array and concatenating the values:
See screenshot below:
Code snippet:
// Customizing Sharepoint List View - Show Tooltip for Long String
// By: [Your Name]
(function () {
var projectTeamContext = {};
projectTeamContext.Templates = {};
projectTeamContext.Templates.Fields = {
"Project_x0020_Team": { "View": ProjectTeamTemplate }
};
SPClientTemplates.TemplateManager.RegisterTemplateOverrides(projectTeamContext);
})();
function ProjectTeamTemplate(ctx) {
var projectTeamValue = ctx.CurrentItem[ctx.CurrentFieldSchema.Name];
//newBodyvalue will contain all display names and be automatically rendered as a tooltip
return "<span title='" + projectTeamValue + "'>" + newBodyValue + "</span>";
}