2

Does anyone know how you can change the background color of list fields same as it excel based on field value. value may be change by the time . I know several ways to do it by row or item record (by using conditionally formatting ) but this is specifically to be able to change value and applied conditional formatting based on the value of the field I have this sharepoint list that has around 200 rows and 40 columns.

2 Answers 2

1

I could suggest two approaches here:

1.) Create a Data View Webpart in Sharepoint Designer.

2.) Create a Calculated column of type number and you can add html there.

I would suggest first one, because there are 40 columns and for the second approach you will have to create an extra column for each column.

1

Yes, HTML/JavaScript in a Calculated Column which colors the row, or cells might be an option for you.

This colors the row based on the Priority field (detailed explanation here)

=[Priority]
&IF([Task Status]="Not Started" , "" ,
  &"<img src=""/_layouts/images/blank.gif"" onload=""{"
  &"this.parentNode.parentNode.parentNode.style.backgroundColor='#"
  &CHOOSE( RIGHT( LEFT( [Priority] , 2) , 1) , "fab" , "fda" , "9fa" )
  &"';"
  &"}"">" 
)

If you want to access individual cells in a row you have to walk the Row with NextSibling JavaScript calls. Best approach is to write the JavaScript first in JSFiddle or Plunkr, once it works wrap the lines in &"" to stuff it in a Calculated Column

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.