Spaces/Official ESi/Scriptaculous & Adv. Tags

Alternate row background colors

Andrew Donnan
posted this on November 25, 2008 15:33

Use this example to create an alternate row background colors. This is sometimes referred to as zebra tables.

<eocrepeatallrecords>
<tr><attribute name="bgColor"><if test="position() mod 2 = 0">#dcdcdf</if><if test="position() mod 2 != 0">white</if></attribute>
<td style="FONT-WEIGHT: normal; FONT-SIZE: 10pt; FONT-STYLE: normal; FONT-FAMILY: Arial" selected="false" rowSpan="1" colSpan="1"><eocfield name="text1"></eocfield></td>

<td style="FONT-WEIGHT: normal; FONT-SIZE: 10pt; FONT-STYLE: normal; FONT-FAMILY: Arial" selected="false" rowSpan="1" colSpan="1" width=""><eocfield name="WO2_1_DT"></eocfield></td>
</tr>
</eocrepeatallrecords>
 

Comments

User photo
Danny Slay

I cannot seem to get this snippet to work on my board? I also tried the other snippet that allows you to allocate a number of rows to change colour, is there any coding in need to change i.e 'test'

September 08, 2009 13:22
User photo
Woodlief, Carla
North Carolina Division of Emergency Management

Is it possible to set the alternate row back ground colors to work on a display with that has sortable columns so when a user sorts by a column the records maintain the alternate row setting?  

 

September 30, 2009 10:56
User photo
Drew Chandler
Kentucky Department for Public Health

Just a note on how to get this to work (after I thought long an hard) - make sure each <tr> and <td> don't have individual bgColor attributes set.

August 17, 2010 13:37
User photo
Brad Pond
ESi

two points for Drew!

August 18, 2010 08:04
User photo
Drew Chandler
Kentucky Department for Public Health

Can I redeem those for development time?

August 18, 2010 08:08
User photo
Brad Pond
ESi

I have consulted the Magic 8 Ball. Reply hazy, try again later.

August 18, 2010 08:37
User photo
JOSHUA K TRAVIS

Instead of using the deprecated "bgcolor" attribute, I'm styling my rows with a class. When using this method, if there was a class previously applied, it simply gets replaced with the new one (or removed depending on the case.) Is there a way to append to a particular attribute without invoking JavaScript?

February 23, 2012 10:45