/// Define a namespace for the custom rendering code var customJSLinkRendering = customJSLinkRendering || {}; // Define a function that declare the custom rendering rules for the target list view customJSLinkRendering.CustomizeFieldRendering = function () { // Define a custom object to configure the rendering template overrides var customRenderingOverride = {}; customRenderingOverride.Templates = {}; customRenderingOverride.Templates.Fields = { // Declare the custom rendering function for the 'View' of field 'Color' 'Clasificaci_x00f3_n': { 'View': customJSLinkRendering.RenderTitleField }, "LinkTitle": { "View": customJSLinkRendering.RenderColoresField } }; customRenderingOverride.OnPostRender = HighlightProductRows; // Register the custom rendering template //SPClientTemplates.TemplateManager.RegisterTemplateOverrides(customRenderingOverride); SP.SOD.executeFunc("clienttemplates.js", "SPClientTemplates", function() { SPClientTemplates.TemplateManager.RegisterTemplateOverrides(customRenderingOverride); }); }; function HighlightProductRows(ctx) { var statusColors = { 'nuevo': 'rgb(241, 241, 241)', 'Usado': '#FFD800', 'DaƱado': '#01DF3A' }; var rows = ctx.ListData.Row; //console.log(rows) // console.log(ctx) for (var i = 7; i < rows.length; i++) { if(i%2==0){ var status = rows[i]["kukv"]; var rowId = GenerateIIDForListItem(ctx, rows[i]); var row = document.getElementById(rowId); row.style.backgroundColor = statusColors['nuevo']; } } } // Declare the custom rendering function for the 'View' of field 'Color' customJSLinkRendering.RenderColoresField = function (context) { var colorField = context.CurrentItem._x0072_pz1; //console.log(context.CurrentItem.Color+", "+context.CurrentItem.Title); // console.log(context.CurrentItem); // Declare a local variable to hold the output color var color = ''; // Evaluate the values of the 'Color' field and render it accordingly switch (colorField) { case 'Red': color = 'red'; break; case 'Green': color = 'green'; break; case 'Blue': color = 'blue'; break; case 'Yellow': color = 'yellow'; break; default: color = 'white'; break; } // Render the output for the 'Color' field return "
"; }; customJSLinkRendering.RenderTitleField = function (context) { //console.log("entra 2"); return "" + context.CurrentItem.Clasificaci_x00f3_n + ""; } customJSLinkRendering.RenderColoresField= function (context) { // console.log("entra 3"); return "" + ctx.CurrentItem.Title + ""; } // Invoke the custom rendering function customJSLinkRendering.CustomizeFieldRendering();