Jump to content
  • 0

Condition format Cells but not Aggregates / sub-totals


StephenS
 Share

Question

Hi, my first post and looking for some assistance please.  Although there are a lot of posts on conditional format, i could not find one to answer my specific issue. 

 

I am looking to conditionally change the background of individual fields (cells) on my tabular results report.  

the report is grouped and has sub totals and a total using aggregates and consists of a large number of fields, each column having a total.  

The report works fine, but I want to change the background of the data fields

i.e. if the data contained = 1. then colour the cell green 

I have so far used this code in my footer 

 

<SCRIPT LANGUAGE="JavaScript">
var elems = document.getElementsByTagName("td");
for (var i=0, m=elems.length; i<m; i++) {
if (elems[i].innerHTML=="1")  { elems[i].style.color="BACK";}
if (elems[i].innerHTML=="1")  { elems[i].style.backgroundColor="LIGHTGREEN";}

}
</SCRIPT>

 

this works but it also colours the background of the totals, subtotals in these fields where the subtotal = 1 as well. 

I have the grouping rows set to a different background colour in the style, which this code above seems to over-write if the total value is a 1

help would be appreciated  thanks  

 

 

 

Link to comment
Share on other sites

2 answers to this question

Recommended Posts

  • 0

try this, basically, it's excluding the elements with the said classes using 'not'

<SCRIPT LANGUAGE="JavaScript">
var elems = document.querySelectorAll("td:not([class^='cbResultSetGroup1Label']):not([class^='cbResultSetTotalsData'])");
for (var i=0, m=elems.length; i<m; i++) {
if (elems[i].innerHTML=="1")  { elems[i].style.color="BACK";}
if (elems[i].innerHTML=="1")  { elems[i].style.backgroundColor="LIGHTGREEN";}

}
</SCRIPT>

 

Link to comment
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
Answer this question...

×   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...
 Share

×
×
  • Create New...