Re: DataObject datasource for DataGrid

From: Date: Tue, 11 Jan 2005 02:11:46 +0000
Subject: Re: DataObject datasource for DataGrid
References: 1  Groups: php.pear.general 
Request: Send a blank email to pear-general+get-16866@lists.php.net to get a copy of this message
> Please answer on the mailing-list. Well I would if the domain doesnt keep bouncing and ifg i can simply press reply instead of replyall ? > > No, bind() is where to pass the options. > > So, either : > > $datagrid->bind($dataobject,$options); > > Or : > > require_once 'Structures/DataGrid/DataSource/DataObject.php'; > $source =& new Structures_DataGrid_DataSource_DataObject(); > $source->bind($dataobject,$options); > $datagrid->bindDataSource($source); > > The first method only works with built-in drivers (dataobject, xml, > etc...). > > The second one will work with any drivers, including those that you may > write by yourself. That is the reason why bindDataSource() exists : > custom drivers. > Its just started to complicate things and become messy. Fatal error: Call to a member function count() on a non-object in /usr/lib/php/Structures/DataGrid/DataSource/DataObject.php on line 206 $options = &PEAR::getStaticProperty('MDB2_DataObject','options'); $config = parse_ini_file('DataObjects/config.ini',TRUE); $options = $config['MDB2_DataObject']; require_once 'DataObjects/Users.php'; require_once 'Structures/DataGrid/DataSource/DataObject.php'; $person = new DataObjects_Users(); //$person->getUsers(); $dg =& new Structures_DataGrid(15,$_GET['page'] ? $_GET['page'] : 1,'HTMLTableCustom'); $source =& new Structures_DataGrid_DataSource_DataObject(); $data = Structures_DataGrid_DataSource::create($person,false,'MDB2'); $options2 = array('generate_columns' => true,'fields' => array('username', 'realname')); $source->bind($data,$options2); $dg->bindDataSource($source); //$dg->addColumn(new Structures_DataGrid_Column('Username', 'username', 'username', array('width' => '40%'),null,$this->getLink())); //$dg->addColumn(new Structures_DataGrid_Column('Realname', 'realname', 'realname', array('width' => '40%'))); //$dg->bind($person,$options2); $dg->renderer->setTableHeaderAttributes(array('class'=>'headertitle')); $dg->renderer->setTableEvenRowAttributes(array('class' => 'even')); $dg->renderer->setTableOddRowAttributes(array('class' => 'odd')); $dg->renderer->setTableCellAttributes(array('class' => 'results')); $dg->renderer->setTableAttribute('cellspacing', '0'); $dg->renderer->setTableAttribute('cellpadding', '0'); $dg->renderer->setTableAttribute('width', '100%'); $this->dg = $dg; $this->datagrid = $dg->renderer->toHTML(); $this->paging = $dg->renderer->getPaging('Custom'); I had to set a var to the renderer because if i call the getpaging method in the flexy templatebefore the toHTML method it wont work because the data isnt collected yet :|

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