0
我在sharepoint的显示模板中有以下代码,我有一个对象数组,并且需要获得以下结果。如何迭代对象数组并打印出其中一个属性
Name1
Name2
Name3
因此,我可以使用工具提示替换Sharepoint多人用户字段的默认呈现。
不过,我不知道如何进行迭代,然后拼接:
截图:
代码:
// List View - Substring Long String Sample
// Muawiyah Shannak , @MuShannak
(function() {
// Create object that have the context information about the field that we want to change it's output render
var projectTeamContext = {};
projectTeamContext.Templates = {};
projectTeamContext.Templates.Fields = {
// Apply the new rendering for Body field on list view
"Project_x0020_Team": { "View": ProjectTeamTemplate }
};
SPClientTemplates.TemplateManager.RegisterTemplateOverrides(projectTeamContext);
})();
// This function provides the rendering logic
function ProjectTeamTemplate(ctx) {
var projectTeamValue = ctx.CurrentItem[ctx.CurrentFieldSchema.Name];
//newBodyvalue should have the list of all display names and it will be rendered as a tooltip automaticlaly
return "<span title='" + projectTeamValue + "'>" + newBodyValue + "</span>";
}
它自动由Sharepoint填充。如果你看到截图,你会看到它的一些对象的数组,我只对Names属性感兴趣。 – 2014-10-07 11:31:18