Jump to content
Sign in to follow this  
mparks

Possible To Color Code Rows By Group In A Tabular Report?

Recommended Posts

Hi MikeP,

 

How are you?

 

I've written the code (you can add an HTML Block, place it the last element, click the Source button and enter the code):

Do not forget to change "id" in two places ([@field:id]) - enter the name of your field with unique value (usually it is a field with the Autonumber DataType) and enter your values in blocks "first possible value", "second possible value". You can use as many blocks as you want.

<div id="[@field:id]"></div>
<SCRIPT LANGUAGE="JavaScript">
var line_id='[@field:id]'; 
var number_records_per_page = 25; //Records per page

var line=document.getElementById(line_id).parentNode.parentNode;
var elems = line.getElementsByTagName("td");
var myColor = "";
var mybgColor = "";
var colorAll = false;
var comparisonText = "";

if(elems[0].innerHTML==" ")
{
   var isGroup = elems[0].parentNode.previousSibling.getElementsByTagName("td")[0];
   if(isGroup.innerHTML==" ")
   {
      for(i = 1; i < number_records_per_page; i++)
      {
         isGroup = isGroup.parentNode.previousSibling.getElementsByTagName("td")[0];
         if(isGroup.innerHTML!=" ") break;
       }
    }
   comparisonText = isGroup.innerHTML;
}
else
{
  comparisonText = elems[0].innerHTML;
}

//first possible value
if (comparisonText =="test"  || comparisonText =="test (Cont.)")  //enter your value instead of test
{
   myColor="blue"; //enter your text color instead of blue
   mybgColor="yellow"; //enter your background color instead of yellow
   var colorAll = true;
}

//second possible value
if (comparisonText =="test" || comparisonText =="test (Cont.)") //enter your value instead of test
{
    myColor="red"; //enter your color instead of red
    mybgColor="green"; //enter your background color instead of green
    var colorAll = true;
}

if(colorAll)
{
   for (var i=0, m=elems.length; i<m; i++)
   {
      elems[i].style.color=myColor;
      elems[i].style.backgroundColor=mybgColor;
    }
}
</SCRIPT>

I'll be grateful, if you tell me if the code works.

Have a nice day!

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
Sign in to follow this  

×
×
  • Create New...