0

Any help? Other fields such as ID works fine..

window.COB = window.COB || {};
window.COB.accordionItem = {
customItemHtml: function (ctx) {

    var accordionItemHtml = "<div title='" + ctx.CurrentItem.Title + "'>" + ctx.CurrentItem.Description;
    accordionItemHtml += "</div>";  
    return accordionItemHtml;
}
};
(function () {
var overrideCtx = {};
overrideCtx.Templates = {};
overrideCtx.Templates.Item = window.COB.accordionItem.customItemHtml;
SPClientTemplates.TemplateManager.RegisterTemplateOverrides(overrideCtx);
})();
2
  • 3
    Make sure fields added in code exists in selected view as well.
    – Deepmala
    Apr 3, 2018 at 3:51
  • Yes Deepmala is right. You can only access the fields that are rendered in the current view. If the field is not present in you view then you will get undefined. Apr 3, 2018 at 7:57

1 Answer 1

1

Your code looks fine so I added it to a demo site and it works. I would suggest doing as @Deepmala suggested and check that Title and Description fields are included in the current view.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.