Please forgive me in advance as I'm new to javascript and SharePoint development.
I've stitched together some code in an attempt to change the full row color of a display list. The column that I'm looking to change is [Status]. I have successfully changed a single column background color, but would like to learn how to do
this with and entire row. As my column has three possible values, I have attempted to use the switch statement. I referenced "http://www.codeproject.com/Articles/620110/SharePoint-Client-Side-Rendering-List-Views" in an attempt to get
started.
1. I created a js file in Sublime text as shown below and posted
PClientTemplates.TemplateManager.RegisterTemplateOverrides({
OnPostRender: function(ctx) {
var rows = ctx.ListData.Row;
for (var i=0;i<rows.length;i++)
var Status = rows[i]["Status"]
switch (Status) {
case "Delivered and Accepted":
{
var rowElementId = GenerateIIDForListItem(ctx, rows[i]);
var tr = document.getElementById(rowElementId);
tr.style.backgroundColor = "#008000";
};
break;
case "Shipped":
{
var rowElementId = GenerateIIDForListItem(ctx, rows[i]);
var tr = document.getElementById(rowElementId);
tr.style.backgroundColor = "#ADFF2F";
};
break;
case "In Production":
{
var rowElementId = GenerateIIDForListItem(ctx, rows[i]);
var tr = document.getElementById(rowElementId);
tr.style.backgroundColor = "#FFFF00";
};
}
});
Followed proper procedure for loading the file in the site root, then adding the appropriate JS Link as I did when using the code that formats only the [Status] column. No joy.