Skip to main content
added 318 characters in body
Source Link
Ganesh Sanap - MVP
  • 46.4k
  • 22
  • 31
  • 63

JSON formatting will not work in SharePoint 2016 classic experience.

For your requirement, you have to use Client Side Rendering in SharePoint.

Try something like below:

SP.SOD.executeFunc("clienttemplates.js", "SPClientTemplates", function() {
SPClientTemplates.TemplateManager.RegisterTemplateOverrides({
  OnPostRender: function(ctx) {
     var rows = ctx.ListData.Row;
     for (var i = 0; i < rows.length; i++) {
         var numVariance = rows[i]["Variance"]; // use internal name of your number column here
         var rowId = GenerateIIDForListItem(ctx, rows[i]);
         var row = document.getElementById(rowId);
 
         // Add your conditions & color formatting here like
         if(numVariance <= 10) {
             row.style.backgroundColor = "#FF0000"; //Red color
         } else if (numVariance <= 50) {
             row.style.backgroundColor = "#FFFF00"; //Yellow color
         } else {
             row.style.backgroundColor = "#00FF00"; //Green color
         }
     }
   }
}); 
});

Where Variance is the internal name of your SharePoint column.

For more information, check this: SP 2013: Highlight Row if Field Value is empty

You can get the internal name of your column by following this article: How to find the Internal name of columns in SharePoint Online?

JSON formatting will not work in SharePoint 2016 classic experience.

For your requirement, you have to use Client Side Rendering in SharePoint.

Try something like below:

SP.SOD.executeFunc("clienttemplates.js", "SPClientTemplates", function() {
SPClientTemplates.TemplateManager.RegisterTemplateOverrides({
  OnPostRender: function(ctx) {
     var rows = ctx.ListData.Row;
     for (var i = 0; i < rows.length; i++) {
         var numVariance = rows[i]["Variance"]; // use internal name of your number column here
         var rowId = GenerateIIDForListItem(ctx, rows[i]);
         var row = document.getElementById(rowId);
 
         // Add your conditions & color formatting here like
         if(numVariance <= 10) {
             row.style.backgroundColor = "#FF0000"; //Red color
         } else if (numVariance <= 50) {
             row.style.backgroundColor = "#FFFF00"; //Yellow color
         } else {
             row.style.backgroundColor = "#00FF00"; //Green color
         }
     }
   }
}); 
});

For more information, check this: SP 2013: Highlight Row if Field Value is empty

JSON formatting will not work in SharePoint 2016 classic experience.

For your requirement, you have to use Client Side Rendering in SharePoint.

Try something like below:

SP.SOD.executeFunc("clienttemplates.js", "SPClientTemplates", function() {
SPClientTemplates.TemplateManager.RegisterTemplateOverrides({
  OnPostRender: function(ctx) {
     var rows = ctx.ListData.Row;
     for (var i = 0; i < rows.length; i++) {
         var numVariance = rows[i]["Variance"]; // use internal name of your number column here
         var rowId = GenerateIIDForListItem(ctx, rows[i]);
         var row = document.getElementById(rowId);
 
         // Add your conditions & color formatting here like
         if(numVariance <= 10) {
             row.style.backgroundColor = "#FF0000"; //Red color
         } else if (numVariance <= 50) {
             row.style.backgroundColor = "#FFFF00"; //Yellow color
         } else {
             row.style.backgroundColor = "#00FF00"; //Green color
         }
     }
   }
}); 
});

Where Variance is the internal name of your SharePoint column.

For more information, check this: SP 2013: Highlight Row if Field Value is empty

You can get the internal name of your column by following this article: How to find the Internal name of columns in SharePoint Online?

added 1049 characters in body
Source Link
Ganesh Sanap - MVP
  • 46.4k
  • 22
  • 31
  • 63

JSON formatting will not work in SharePoint 2016 classic experience.

For your requirement, you have to use Client Side Rendering in SharePoint.

Try something like below:

SP.SOD.executeFunc("clienttemplates.js", "SPClientTemplates", function() {
SPClientTemplates.TemplateManager.RegisterTemplateOverrides({
  OnPostRender: function(ctx) {
     var rows = ctx.ListData.Row;
     for (var i = 0; i < rows.length; i++) {
         var numVariance = rows[i]["Variance"]; // use internal name of your number column here
         var rowId = GenerateIIDForListItem(ctx, rows[i]);
         var row = document.getElementById(rowId);
 
         // Add your conditions & color formatting here like
         if(numVariance <= 10) {
             row.style.backgroundColor = "#FF0000"; //Red color
         } else if (numVariance <= 50) {
             row.style.backgroundColor = "#FFFF00"; //Yellow color
         } else {
             row.style.backgroundColor = "#00FF00"; //Green color
         }
     }
   }
}); 
});

For more information, check this: SP 2013: Highlight Row if Field Value is empty

JSON formatting will not work in SharePoint 2016 classic experience.

For your requirement, you have to use Client Side Rendering in SharePoint.

JSON formatting will not work in SharePoint 2016 classic experience.

For your requirement, you have to use Client Side Rendering in SharePoint.

Try something like below:

SP.SOD.executeFunc("clienttemplates.js", "SPClientTemplates", function() {
SPClientTemplates.TemplateManager.RegisterTemplateOverrides({
  OnPostRender: function(ctx) {
     var rows = ctx.ListData.Row;
     for (var i = 0; i < rows.length; i++) {
         var numVariance = rows[i]["Variance"]; // use internal name of your number column here
         var rowId = GenerateIIDForListItem(ctx, rows[i]);
         var row = document.getElementById(rowId);
 
         // Add your conditions & color formatting here like
         if(numVariance <= 10) {
             row.style.backgroundColor = "#FF0000"; //Red color
         } else if (numVariance <= 50) {
             row.style.backgroundColor = "#FFFF00"; //Yellow color
         } else {
             row.style.backgroundColor = "#00FF00"; //Green color
         }
     }
   }
}); 
});

For more information, check this: SP 2013: Highlight Row if Field Value is empty

Source Link
Ganesh Sanap - MVP
  • 46.4k
  • 22
  • 31
  • 63

JSON formatting will not work in SharePoint 2016 classic experience.

For your requirement, you have to use Client Side Rendering in SharePoint.