Stump the Panel » Site Managers and Site Collection Managers

Customize a list view with colors

(3 posts)
  1. DS1
    Member

    I have a list view which I have been able to add colors to indicate progress in a status colum - Green (On Time) Yellow (Danger)and Red (Miss). I've been able to accomplish this for the standard view by using a Content Editor web part and using the following code:

    <script type="text/javascript" language="javascript">
    var x = document.getElementsByTagName("TD") // find all of the TDs
    var i=0;
    for (i=0;i<x.length;i++)
    if (x[i].className=="ms-vb2") //find the TDs styled for lists
    {
    if (x[i].innerHTML=="Green-OnTime") //find the data to use to determine the color
    {
    x[i].style.backgroundColor='green'; // set the background color
    x[i].style.color='white'; //set the font color
    }

    if (x[i].innerHTML=="Yellow-Danger") //find the data to use to determine the color
    {
    x[i].style.backgroundColor='Gold'; // set the background color
    x[i].style.color='black'; //set the font color
    }

    if (x[i].innerHTML=="Red-Miss") //find the data to use to determine the color
    {
    x[i].style.backgroundColor='red'; // set the background color
    x[i].style.color='white'; //set the font color
    }
    }

    </script>

    The problem is I cannot get this to work if the view is a Data Sheet View in the same list. Any suggestions for getting this to work in a data sheet view?

    Posted 3 days ago #
  2. It probably has different syntax and markup in datasheet view. Use IE Developer Toolbar to see if you can find the syntax it needs.

    Posted 2 days ago #
  3. Nelson
    Member

    Hello DS1,

    I'm interested in your project -- I've got something coming up that may have similar status ranges. Can you please tell me what calculated fields you have in addition to the above script.

    Thank You

    Posted 2 days ago #

RSS feed for this topic

Reply

You must log in to post.