mental exercise

A place for users and developers of the Xataface to discuss and receive support.

mental exercise

Postby 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
Martin Pruss
 
Posts: 61
Joined: Tue Oct 23, 2007 2:22 pm
Location: Berlin

Postby 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.
shannah
 
Posts: 4457
Joined: Wed Dec 31, 1969 5:00 pm

Postby 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
Martin Pruss
 
Posts: 61
Joined: Tue Oct 23, 2007 2:22 pm
Location: Berlin


Return to Xataface Users

Who is online

Users browsing this forum: No registered users and 2 guests

cron
Powered by Dataface
© 2005-2007 Steve Hannah All rights reserved