1

I'm having difficult rendering my JSLink file on a Custom List. My code looks to be fine from debugging, and I don't see any immediate issues if I include the code in a Script Editor, but my changes still aren't being applied. There are some weird issues going on in this site collection with custom lists in general; I can't tell if there's something inherently wrong/corrupt with this List Template Type or if it is my code.

Please advise.

Code included in .js file:

(function(){

var itemCtx = {};
itemCtx.Templates = {};

itemCtx.Templates.Header = "<div id='container'><table><tr><td>Project Category</td><td>Project</td><td>Project Summary</td><td>Toolkit Compliance</td><td>Project Lead</td></tr>";
itemCtx.Templates.Item = ItemOverride;
itemCtx.Templates.Footer = "</table></div>";

itemCtx.BaseViewID = 1;
itemCtx.ListTemplateType = 100;

SPClientTemplates.TemplateManager.RegisterTemplateOverrides(itemCtx);

})();

function ItemOverride(ctx) {

    var projCat = ctx.CurrentItem.projCat;
    var projSum = ctx.CurrentItem.Summary;
    var project = ctx.CurrentItem.Project;
    var projLead = ctx.CurrentItem.projLead;
    var projComp = ctx.CurrentItem.artCompliance;
    var html = "<tr class='content'><td><div id='projCat'>" + projCat + "</div></td><td>" + project + "</td><td>" + projSum + "</td><td>" + projComp + "</td><td>" + projLead + "</td></tr>";

        if (projCat == "Change Mangement") {
            $("div#projCat").addClass("cm");
        }

        else if (projCat == "Communications") {
            $("div#projCat").addClass("comms");
        }

        else if (projCat == "Modernization") {
            $("div#projCat").addClass("mod");
        }

        else if (projCat == "OBPI Support") {
            $("div#projCat").addClass("obpi");
        }


        else if (projCat == "Process Improvement") {
            $("div#projCat").addClass("pi");
        }

        else (projCat == "Project Management Standardization"){
            $("div#projCat").addClass ("pms");
        }
    return html;

}

The JSLink file was uploaded directly to the Masterpages Gallery as a Display Template Code. (There was not an option for JavaScript Display Template). And I copied and pasted an absolute URL versus a relative one for now.

*Also, two of the fields are lookup columns if that makes any difference.

2
  • What is the value of the JSLink property of the list web part configuration?
    – Drago Z.C.
    Commented Nov 24, 2017 at 14:56
  • /sites/intra/_catalogs/masterpage/projDash.js Commented Nov 24, 2017 at 15:06

1 Answer 1

2

Please make sure you are using the ~sitecollection URL token in your JSLink URL. In your case the URL should be ~sitecollection/_catalogs/.... Also, please make sure you check in, publish and approve your JS template file so that end users would be able to see the effect.

0

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.