Re: Changing options when rendering twice datagrid
| From: | m dot dhooge at enertecgroup dot com | Date: | Tue, 13 Jun 2006 09:23:59 +0000 |
| Subject: | Re: Changing options when rendering twice datagrid | ||
| References: | 1 2 | Groups: | php.pear.general |
| Request: | Send a blank email to pear-general+get-24334@lists.php.net to get a copy of this message | ||
>> Is there a clear
>> definition of what Structures_DataGrid_Renderer::init() is expected to
>> do?
>
> Hmm, that's clearly stated in Renderer.php:
Well, in fact, my question should have been:
Is there a clear definition of WHEN Structures_DataGrid_Renderer::init() is
CALLED? And as important, when not called? Or stated differently, does
Datagrid guarantee that it will only call once this method?
> Please provide a code example if this does not work for you.
>
> This works for me (not beautiful, but working *g*):
> $dg->render(null,
> array('headerAttributes' => array('bgcolor' =>
> 'red')));
> $dg->render(null,
> array('headerAttributes' => array('bgcolor' =>
> 'green')));
According to me, this shouldn't... but you're right this works :-?
And I think I found the culprit: _restoreRenderer().
function _restoreRenderer()
{
if (isset($this->_rendererBackup)) {
$this->_renderer =& $this->_rendererBackup;
$this->_rendererType = $this->_rendererTypeBackup;
} else if (@is_null($this->_rendererBackup)) {
unset($this->_renderer);
$this->_rendererType = null;
}
unset($this->_rendererBackup);
$this->_rendererTypeBackup = null;
}
The 2nd if is always true even if unset, so in your example the current
renderer is unset. And when render() is called a second time, a new default
renderer is created which will take the given parameters into account since
it isn't already built.
Or did I miss something?
--
Michel