I have the following JSLink template for rendering items in a custom list containing a number of columns of type 'Publishing HTML'. The template is used on both the default view (AllItems.aspx) and the display form (DispForm.aspx).
The ‘View’ method works as intended. The ‘DisplayForm’ method does not.
Debugging in IE developer tools shows that the ctx.CurrentItem object does not contain any of the 'Publishing HTML' fields.
Has anyone encountered the same or similar issue? Is this a restriction by design (presumably for security reasons)?
All ideas are very welcome!
var myNamespace = mynamespace || {};
myNamespace.CustomizeFieldRendering = function () {
var overrideCtx = {
Templates: {
Fields: {
'TestPublishingHTMLColumn': { 'DisplayForm' : myNamespace.displayMethod},
'TestPublishingHTMLColumn': { 'View' : myNamespace.viewMethod}
}
}
};
SPClientTemplates.TemplateManager.RegisterTemplateOverrides(overrideCtx);
}
myNamespace.displayMethod = function (ctx) {
var output = [];
var field = ctx.CurrentItem[ctx.CurrentFieldSchema.Name];
//Check field contains data
if (field && field.length > 0) {
//Process the content here...
}
return output;
}
myNamespace.viewMethod = function (ctx) {
var output = [];
var field = ctx.CurrentItem[ctx.CurrentFieldSchema.Name];
//Check field contains data
if (field && field.length > 0) {
//Process the content here...
}
return output;
}
myNamespace.CustomizeFieldRendering();