mental exercise
Archived from the Xataface Users forum.
Martin Pruss — Tue Apr 07, 2009 2:08 am
Hi Steve…
Obvously you are busy these days…
if you’ll find some time to help
here is a tricky problem:
I’d like to modify the css of a table row
(I know how to do that) by a condition.
Usually the rows are swiched from odd to even.
I was wondering if it was possible to group
entries with the same Date by applying the same
background color.
- Code: Select all
- `[b]!!pseudocode[/b]
function css__tableRowClass(&$record){
if ( $record->val(‘date’) == ‘$record->val(‘date’) of a previous record’ ){
return ‘bgcolor of the previous entry with the same date’;
}else return ‘’; }`
for this the function in the table delegate class
has to be aware of its own status “odd/even”
and as if this wasn’t complicated
enough, $record->val(‘date’) has to be compared to the
other rows…
mmhh…
I must confess I am not clever enough for that challenge
but maybe you are provoked by my dilettantism
thanks and cheers
martin
shannah — Sun Apr 12, 2009 11:16 am
Hi Martin,
This is a bit of a hack, but you could “hope” that this function is called once per row. You could then use a static variable to track the date of the previous row:
- Code: Select all
function css__tableRowClass(&$record){ static $even = false; static $prevDate = -1; if ( $record->strval('date') != $prevDate ){ $prevDate = $record->strval('date'); $even = !$even; } return ($even?'even':'odd'); }
Or something along those lines.
Martin Pruss — Tue Apr 14, 2009 1:43 am
Hi Steve
Thanks for the hack…
it was’nt working reliable out of the box but
i’ll experiment with the static variable to get this working
cheers
Martin