On April 27, 2024, our Sign-in and Create Account options will be unavailable from 9am-12pm ET. During this maintenance window, developer account access and free trial registration will be unavailable.

Alternating colors with hidden rows

JasonW
edited 2013 11 in DevShare Downloads #1
When alternating row colors are need you usually can just add an expression in the highlights of the detail row that looks like:<br />
<br />
row.__rownum%2 equal 0 which is true every other row. This does not work well if the visibility expression of the row is culling several rows. An alternate approach is to use an onCreate script for the detail row, with code similar to the folllowing:
if( typeof jj == 'undefined'  ){
jj=0;
}
if( (this.getStyle().visibleFormat != "all") ){
 if( jj !=0 ){
  this.getStyle().backgroundColor="Silver";
  jj=0;
 }else{
  jj++;
 } 
}
<br />
This script first initializes a counter (jj). When a row is culled because of visibility the this.getStyle().visibleFormat property will specify all the formats that the row is culled for. For example if the row is only dropped in PDF the visibleFormat will contain the value pdf. If the row is not culled the visibleFormat value will be null. So in the above script we toggle the jj variable every visible row.