[Seaside] How to alternate table row colors without WATableReport

Sorensen sorens at surfy.net
Sun Mar 22 20:22:49 UTC 2009



Lukas Renggli wrote:
> 
>> html table: [
>>     collection withIndexDo: [:each :index |
>>          html tableRow: [
>>              html div class: ('row' , (index \\ 2) printString); with: [
>>                   html
>>                        tableData: each stuff1;
>>                        tableData: each stuff2]]]]
> 
> That's not valid HTML. Assign the class to the #tableRow and avoid
> putting a #div around the #tableData. See the senders of #table and
> #table: for various examples.
> 

Thanks to both Gerhard and Lukas for pointing out the problem with my
Seaside code.  I changed it to:

html table: [
     collection withIndexDo: [:each :index |
           html tableRow class: ('row' , (index \\ 2) printString); with: [
                 html
                       tableData: each stuff1;
                       tableData: each stuff2]]]

and the code works.

After looking at the result, though, I wonder if I may ask how to go about
implementing a further enhancement.

The application that I wrote is in essence an amortization table in which
each row corresponds to a month; there are many months of data, so
alternating the row colors helps make the table more readable. In my
stylesheet, I have

.row1 {background-color: #ddd; color #000}
.row2 {background-color: #888; color#000}

The enhancement I have in mind involves grouping the colors so that each
year holds the same set of alternating row colors, but as the year changes
then the alternating row colors take on a different shade of color.  Here's
an example:

2009 Jan   background-color: #ddd; color #000
2009 Feb   background-color: #ff0; color#000
2009 Mar   background-color: #ddd; color #000
2009 Apr   background-color: #ff0; color#000
...
2009 Nov   background-color: #ddd; color #000
2009 Dev   background-color: #ff0; color#000

2010 Jan    background-color: #ddd; color #000
2010 Feb    background-color: #0ff; color#000
2010 Mar    background-color: #ddd; color #000
2010 Apr    background-color: #0ff; color#000
...
2010 Nov    background-color: #ddd; color #000
2010 Dec    background-color: #0ff; color#000

Rather than try to define tags in the stylesheet

.row0 {background-color: #ddd; color #000}
.row1 {background-color: #ff0; color#000}
.row2 {background-color: #0ff; color #000}
.row3 {background-color: #f0f; color#000}

I'd rather specify the row colors programatically in my Seaside code.

This doesn't seem like a difficult thing to do, but I'm afraid my Seaside
HTML rendering ability is rather weak at the moment.  Can someone help me
out?

Thanks,  Soren


-- 
View this message in context: http://www.nabble.com/How-to-alternate-table-row-colors-without-WATableReport-tp22512359p22650151.html
Sent from the Squeak - Seaside mailing list archive at Nabble.com.



More information about the seaside mailing list