I'm hoping that you can help me with this issue. I've been wrestling with this one for days. I've been following everyone's posts for OnPostRender. I want to change the background color of the row based on a person field called Lead Capture. For some reason it will only change the background color of the first row. It seems as if the code leaves the loop after the first row and I can't figure out why. Thank you for your help.
(function () {
var overrideCtx = {};
overrideCtx.Templates = {};
overrideCtx.OnPostRender = HighlightRowOverride;
// Register the template overrides.
SPClientTemplates.TemplateManager.RegisterTemplateOverrides(overrideCtx);
})();
var statusColors = {
'Jimmy' : '#8B0000',
'Robby' : '#ff6a00',
'Ricky' : '#1E90FF',
'Sally' : '#4B0082',
'Jane' : '#B8860B',
'Roy' : '#FFD700',
'Mike' : '#006400'};
function HighlightRowOverride(ctx)
{
var rows = ctx.ListData.Row;
var i;
for (i = 0; i < rows.length; i++)
{
var users = rows[i]["Lead_x0020_Capture"];
var curUserName = users[i].title;
var status = curUserName;
var rowId = GenerateIIDForListItem(ctx, rows[i]);
var row = document.getElementById(rowId);
if (row != null)
{
row.style.backgroundColor = statusColors[status];
}
}
}
rows.length
?