1

I created a simple JSLink CSR test that should override the view in SharePoint when an individual list item is displayed.

The viewTemplate function is never called. Here is the JSLink JavaScript file. I walked through the code in debugger and I step through all the lines of code without an error.

SP.SOD.executeFunc("clienttemplates.js", "SPClientTemplates", function () { 

    // Create object that have the context information about the field that we want to change it's output render  
    var formTemplate = {}; 
    formTemplate.Templates = {}; 
    formTemplate.Templates.View = viewTemplate; 
    SPClientTemplates.TemplateManager.RegisterTemplateOverrides(formTemplate); 
}); 


function viewTemplate(ctx) { 
var formTable = "";

    formTable = "<div style='width:100%;float:left;padding:0 50px 15px 0;'>" + 
"<h3>It worked</h3>" +
"</div>";
    return formTable; 
}

Thanks in advance. Hal.

Bergi
  • 630,263
  • 148
  • 957
  • 1,375
Hal Hayes
  • 11
  • 3

2 Answers2

0

Looks like you're trying to render a custom display. If that is the case, make you select custom from the drop down.

Johnny B
  • 21
  • 1
  • 3
0

Here is an image of that section in editing the web part that Johnny B referred to below. It appears right below the JSLink field.

CSR Render Mode

Hal Hayes
  • 11
  • 3