I follow this tutorial to get column painted
I have a list called: "Seguimiento de Sistemas"
It have a column with select list called: "Status"
Now I have that list in a WebPart and js into MasterPage and I link JS using JSLink into my WebPart.
JS
(function () {
var statusFieldCtx = {};
statusFieldCtx.Templates = {};
statusFieldCtx.Templates.Fields = {
"Status": {
"View": StatusFieldViewTemplate
}
};
SPClientTemplates.TemplateManager.RegisterTemplateOverrides(
statusFieldCtx
);
})();
function StatusFieldViewTemplate(ctx) {
var _statusValue = ctx.CurrentItem.Status;
if (_statusValue == 'Completed')
{
return "<img src='/SiteAssets/green.png'/>";
}
if (_statusValue == 'In Progress')
{
return "<img src='/SiteAssets/yellow.png'/>";
}
if (_statusValue == 'Not Started')
{
return "<img src='/SiteAssets/red.png'/>";
}
}
I debbug it, problem is when page load it never hint or execute:
function StatusFieldViewTemplate(ctx) {...
like it no exist. Can someone help me what is wrong there?
Note: If I use console.log(ctx)
before function StatusFieldViewTemplate(ctx) {...
I get undefined
UPDATE JS load correctly on masterpage and I can access debug all before function commented above