Alternate Colors for row blocks

Hello.

I need to do a twist on the alternate row colors. I looked at cycle(), but that appears to be table row specific.

I have a table header. Then I have up to 3 table rows that are grouped together in a loop. I'd like to alternate colors per group, not per row. If I put the 3 table rows into a separate table, it makes a mess out of my table and table header.

Any ideas?

Thanks.

So something like:

class="<%= cycle('green', 'green', 'green', 'white', 'white', 'white') %>">

-Rob

Rob Biedenharn http://agileconsultingllc.com Rob@AgileConsultingLLC.com

Rob Biedenharn wrote:

class="<%= cycle('green', 'green', 'green', 'white', 'white', 'white') %>">

Thanks for the suggestion, but I'm not sure this will work in my situation.

There is always going to be a first(x) and second(y) row. The third(z) row may be populated based on the results of the second row. If "y" finds a record, then the "z" row created with a value . If "y" does not find a value, then it ends the loop and goes to the next "x" record.

Additionally I have the records split into 3 rows.

The code looks similar to this.

<% for x in @x.id %>   <tr><td><%=h x.id %></td></tr>   <tr><td><%=h y.id %></td></tr>   <%# if y returns a value %>   <tr><td><%=h z.id %></td></tr> <% end %>

Becca Girl wrote:

Rob Biedenharn wrote:
class="<%= cycle('green', 'green', 'green', 'white', 'white', 'white')
%>">

Thanks for the suggestion, but I'm not sure this will work in my situation.
There is always going to be a first(x) and second(y) row. The third(z) row may be populated based on the results of the second row. If "y" finds a record, then the "z" row created with a value . If "y" does not find a value, then it ends the loop and goes to the next "x" record.
Additionally I have the records split into 3 rows.
The code looks similar to this.
<% for x in @x.id %>
<tr><td><%=h x.id %></td></tr>
<tr><td><%=h y.id %></td></tr>
<%# if y returns a value %>
<tr><td><%=h z.id %></td></tr>
<% end %>

Call "cycle’ only once inside each loop, such as…

  <% for x in @x.id %>
<% row_group_class = cycle('green','white') %>
<tr class=<%= row_group_class %>><td><%=h x.id %></td></tr>
<tr class=<%= row_group_class %>><td><%=h y.id %></td></tr>
<%# if y returns a value %>
<tr class=<%= row_group_class %>><td><%=h z.id %></td></tr>
<% end %>

Jon Garvin wrote:

Call "cycle' only once inside each loop, such as...

<% for x in @x.id %>   <% row_group_class = cycle('green','white') %>   <tr class=<%= row_group_class %>><td><%=h x.id %></td></tr>   <tr class=<%= row_group_class %>><td><%=h y.id %></td></tr>   <%# if y returns a value %>   <tr class=<%= row_group_class %>><td><%=h z.id %></td></tr> <% end %>

That's perfect! Thanks!!!!