Making an attempt to paint rows based mostly off of the worth of the “Standing” column
Nevertheless I can’t get it working because it retains giving the next errors:
TypeError: Can not learn property ‘model’ of null
TypeError: Can not learn property ‘model’ of nullTypeError: Can not learn
property ‘_events’ of null
Debugging it, it appears to be failing on: var row = doc.getElementById(rowId);
and at all times developing null.
Any concepts why it would not be capable to execute the getElementByID? This appears to be occuring whether or not I add it as a JSLink, or put it in a script or content material editor… at all times the identical error.
Code:
SP.SOD.executeFunc("clienttemplates.js", "SPClientTemplates", perform() {
SPClientTemplates.TemplateManager.RegisterTemplateOverrides({
OnPostRender: perform(ctx) {
var statusColors = {
'Pending Investigation' : '#FFF1AD',
'Below Investigation' : '#FFD800',
'Accomplished' : '#01DF3A'
};
var rows = ctx.ListData.Row;
for (var i=0;i<rows.size;i++)
{
var standing = rows[i]["Status"];
var rowId = GenerateIIDForListItem(ctx, rows[i]);
var row = doc.getElementById(rowId);
row.model.backgroundColor = statusColors[status];
}
}
});
});