(function () {
var itemCtx = {};
itemCtx.Templates = {};
itemCtx.Templates.Header = "<div><b>Announcements</b></div><table>";
itemCtx.Templates.Item = ItemOverrideFun;
itemCtx.Templates.Footer = "</table>";
SPClientTemplates.TemplateManager.RegisterTemplateOverrides(itemCtx);
})();
function ItemOverrideFun(ctx) {
var _announcementTitle = ctx.CurrentItem.Title;
var _announcementID = ctx.CurrentItem.ID;
return "<tr><td><p><b>" + _announcementTitle + "</b></p></td></tr>";
}
---with this code m getting values row by row as below:
1)Book Your Summer Vacation Now
2)We were Recognized as Exceptional Service
3)Ancmnts
4)XYX
----but i need to display it side by side as
1)Book Your Summer Vacation Now 2) We were Recognized as Exceptional Service
3)Ancmnts 4) XYZ
so i have made some changes in the code and used an array for it, now m getting format as two columns but m not getting data as array value is displayed undefined.
(function() {
var itemCtx = {};
itemCtx.Templates = {};
enter code here
itemCtx.Templates.Header = "<div><b>Announcements</b></div>";
itemCtx.Templates.Item = ItemOverrideFun;
itemCtx.Templates.Footer = "</table>";
SPClientTemplates.TemplateManager.RegisterTemplateOverrides(itemCtx);
})();
function ItemOverrideFun(ctx) {
var _announcementTitle = ctx.CurrentItem.Title;
var _announcementID = ctx.CurrentItem.ID;
var myArray = new Array();
for (var i = 0; i < 5; i++) {
myArray[i] = _announcementTitle;
}
return "<table><tr><td><p><b>" + myArray[i] + "</b></p></td><td><p><b> " + myArray[i + 1] + "</p></b></td></tr></table>";
}
Array value is not coming in its proper way,it is displaying undefined in in place of its value.
Result:
Announcements
undefined undefined
undefined undefined
undefined undefined
I guess you need to render list items from Announcements list horizontally, right?
The following example demonstrates how to accomplish it: