Categories > TinyButStrong general >

different groupping

The forum is closed. Please use Stack Overflow for submitting new questions. Use tags: tinybutstrong , opentbs
By: zsom
Date: 2007-09-20
Time: 15:28

different groupping

Hi!

I have some data like this:
Name City
name1 city1
name2 city1
name3 city3
name4 city6
name5 city6
name6 city6
name7 city9
etc...

The data are ordered by City
I'd like to display theese as a table. The color of a row depends on the City, but there will be only two color. And theese colors would change, if the city of the previous row is different then the current one.

For example :
Name City => row color
name1 city1 => blue
name2 city1 => blue
name3 city3 => red
name4 city6 => blue
name5 city6 => blue
name6 city6 => blue
name7 city9 => red
name8 city9 => red

Is it possible with TBS?

Thanks, and sorry for my English
By: Skrol29
Date: 2007-09-20
Time: 19:13

Re: different groupping

The more simple way of doing this is to use a "ondata" function to create a news field that would be 1 or 2 depending to the cities of the previous record and current one.

Then you can create two conditional sections for your block: one for field=1, one for field=2.
By: zsom
Date: 2007-09-20
Time: 22:59

Re: different groupping

Thanks, it's simple and it's working.

But instead of conditional sections, i used the new field, for changing the CSS class of the row.
<style>
.row0 {background-color: red;}
.row1 {background-color: blue;}
</style>

<tr class="row[blk.toggler;block=tr;ondata=blkToggler]">