3

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();
1
  • 1
    I am having same issue. Can anybody help out in this
    – Richa Jain
    Commented May 26, 2017 at 14:57

1 Answer 1

0

I resolved this by having to run powershell script to add the publishing image column to the list.

You can only change the field name of the publishing image using powershell and in my case I changed the field name to read "PublishingPageImage" and the display name as "Page Image".

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.