Re: DataGrid and addColumn()

From: Date: Tue, 16 Aug 2005 15:56:37 +0000
Subject: Re: DataGrid and addColumn()
References: 1  Groups: php.pear.general 
Request: Send a blank email to pear-general+get-20431@lists.php.net to get a copy of this message
Markus Wolff a écrit :
Hi all, short question about Structures_DataGrid: I'm trying to make a generic base class for my DB_DataObjects, which has a getGrid() method. FormBuilder integration is on, so all the columns that are to be displayed are already determined by the individual DataObjects' properties. However, I'd like for all grids to have at least one extra column ("Edit record"), which I wanted to add via addColumn() in the base DataObject. Right now, I don't seem to be able to do that, because once addColumn() is called, the auto-generation of all the other columns won't happen (in other words, I *only* get the edit column). I use this weird workaround (copied from justin patrin) for the same reasons:
$dg = &new Structures_DataGrid($limit); $dgoptions = array('generate_columns' => true, 'formbuilder_integration' => true); $dg->bind($do, $dgoptions); $dg->numRows = $dg->_dataSource->count(); foreach ($this->dg->_dataSource->getColumns() as $col) { $this->dg->addColumn($col); } $dg->addColumn(new Structures_DataGrid_Column('Modifier', null, null, null, null, __CLASS__ . '::formatEditLink($format=' . $editFormat . ',$idField=' . $this->idField . ')')); dg->_dataSource->setOptions(array('generate_columns' => false)); Thus, you can add custom columns while continue to benefit of the auto generation of columns from formbuilder_integration. I think this and the formatter (impossible to use array($this,'formatterMethod)) are the two big limitations of structures_datagrid. I you find a more elegant solution, let us know. Didier ___________________________________________________________________________ Appel audio GRATUIT partout dans le monde avec le nouveau Yahoo! Messenger Téléchargez cette version sur http://fr.messenger.yahoo.com

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