Re: Structures_DataGrid set row attributes

From: Date: Fri, 21 Oct 2005 19:56:30 +0000
Subject: Re: Structures_DataGrid set row attributes
References: 1  Groups: php.pear.general 
Request: Send a blank email to pear-general+get-21585@lists.php.net to get a copy of this message
On 10/21/05, Gerard Bowe <gerard.bowe@jrc.it> wrote: > Is it possible to set the row attributes on the fly. > > I am using Structures_DataGrid together with DB_DataObject (works very > well) where I pass an Orders DO into DG. It outputs a list of orders > (date, ordered by, ordered from, etc, and status (ordered, arrived, > onhold)). > I would like to use the status field to format the output list (<tr > class='status'>, but I do not know how to do this with DataGrid. > > I can only find info on using > > $dg->renderer->setTableEvenRowAttributes(array('bgcolor' => > '#FFFFFF')); > $dg->renderer->setTableOddRowAttributes(array('bgcolor' => > '#EEEEEE')); > I'm pretty such such a thing is not currently possible with SDG. However, it shouldn't be too hard to do with sime simple JS. You could add a formatter for your status column with something like this: function statusFormatter($params) { static $id = 0; return $params['record']['status'].'<span id="status'.$id.'"></span> <script language="javascript"> node = document.getElementById("status'.$id.'"); while (node && node.nodeName != "TR") node = node.parentNode; if (node) { node.className = "'.$params['record']['status'].'"; } </script> '; ++$id; } Yes, I know this is a hack. ;-) -- Justin Patrin

« previous php.pear.general (#21585) next »