1

I have a very simple JScript that replaces a list view value with an image based upon criteria. Seems to work ok, but the return view is a small with box with a line through it. My images are 20px x 20px. Is there a permissions issue or image size issue I am missing?

enter image description here

(function () {

    var statusFieldCtx = {};
    statusFieldCtx.Templates = {};
    statusFieldCtx.Templates.Fields = {
        "ProspectRate": {
            "View": StatusFieldViewTemplate
        }
    };

    SPClientTemplates.TemplateManager.RegisterTemplateOverrides(statusFieldCtx);
})();

function StatusFieldViewTemplate(ctx) {



    if (ctx.CurrentItem.ProspectRate <=25)
    {
        return "<img src='/SiteAssets/Pick_Red-01.png'>";
    }
    if (ctx.CurrentItem.ProspectRate > 25 && ctx.CurrentItem.ProspectRate <=50)
    {
        return "<img src='/SiteAssets/Pick_Orange-01.png'>";
    }
    if (ctx.CurrentItem.ProspectRate > 50 && ctx.CurrentItem.ProspectRate < 70)
    {
        return "<img src='/SiteAssets/Pick_Yellow-01.png'>";
    }
    if (ctx.CurrentItem.ProspectRate >70)
    {
        return "<img src='/SiteAssets/Pick_Green-01.png'>";
    }
}
2

This was a very simple fix that involved putting the entire URL into the return statement.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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