Re: How to set cell styles in DataGrid CVS?
| From: | dondo | Date: | Sun, 07 May 2006 21:17:51 +0000 |
| Subject: | Re: How to set cell styles in DataGrid CVS? | ||
| Groups: | php.pear.general | ||
| Request: | Send a blank email to pear-general+get-23985@lists.php.net to get a copy of this message | ||
I'm resending this because my last mail was unreadable.
Also, I posted the code on my homepage which is probably much easier to read than the inline email
below.
Link to my class that extends Structures_DataGrid_Renderer_HTMLTable:
http://www.bryandonovan.com/pastes/MyDataRenderer.html
Link to script that creates the datagrid object, renders it, etc.:
http://www.bryandonovan.com/pastes/build_table.html
Here's the original mail that got garbled:
---
Thanks Mark. I'll try it with the 'columnAttributes' of the HTMLTable
renderer. Below is the basic code I'm using.
$dg =& new Structures_DataGrid($linesToDisplay,null,DATAGRID_RENDER_TABLE);
$dg->bind($res);
[...]
//for each column...
$col_attribs = array('class'=>"$class");
$column = new Structures_DataGrid_Column($c['title'],
$colname,$colname,$col_attribs, '0',$callbackString);
$dg->addColumn($column);
However, I should note that I am attaching my own renderer as follows:
$myRenderer = new MyDataRenderer();
$dg->attachRenderer($thtRenderer);
$r = $dg->getRenderer();
$r->init();
$r->setCurrentSorting($currentSorting);
$r->setDefaultSorting($defaultSorting);
$r->setTableOddRowAttributes($oddRowAttribs);
$r->setTableEvenRowAttributes($evenRowAttribs);
$r->build();$r->render();
My renderer simply extends Structures_DataGrid_Renderer_HTMLTable and
overloads the buildHeader() function. The only difference between my
buildHeader() and the one in Structures_DataGrid_Renderer_HTMLTable is
that I set default sort directions for each column. I left everything
below the "// Build HTTP query" comment in tact.
Regards,
Bryan
> Subject:
> [PEAR] Re: How to set cell styles in DataGrid CVS?
> From:
> Mark Wiesemann
> Date:
> Sun, 7 May 2006 19:42:05 +0200
> To:
> pear-general@lists.php.net
>
> To:
> pear-general@lists.php.net
>
>
>dondo wrote:
>
>
>
>>I'm currently using the latest CVS version of Structures::DataGrid
>>and would like to assign CSS classes to each cell of a table. Maybe
>>the answer is "wait until the next release and stop using CVS!", but
>>maybe this is an easy question to answer. More specifically, I want
>>the columns to look something like:
>>
>>
>
>Two possibilities:
>
>(1) Use the option 'columnAttributes' of the HTMLTable renderer.
>
>(2) Create your own HTML_Table instance, call $dg->fill() with this
>instance and then set your attributes to the table columns via
>$table->setColAttributes().
>
>Both of these possibilities will only work with the CVS version.
>
>And: The column attributes from the column object should work as before.
>If they do not, then please provide a short example code - either here
>or via the bug tracker. Thanks.
>
>Regards,
>Mark
>
>
>
> --- End Attached Message---
_______________________________________________
No banners. No pop-ups. No kidding.
Make My Way your home on the Web - http://www.myway.com