Re: Re: Changing options when rendering twice datagrid

From: Date: Tue, 13 Jun 2006 13:10:15 +0000
Subject: Re: Re: Changing options when rendering twice datagrid
References: 1 2 3 4 5  Groups: php.pear.general 
Request: Send a blank email to pear-general+get-24343@lists.php.net to get a copy of this message
Michel D'HOOGE wrote:
Olivier Guilyardi wrote:
Why shouldn't it work ?
In DataGrid::render(), there is:
        $this->_renderer->isBuilt() || $this->build();
        $test = $this->_renderer->render();
So, in the case (at least) of the HTMLTable renderer, the options are only taken into account during the build. So when DG::render() is called for the second time, build should not be called. And thus, we should have twice the same output (besides odd and even rows which are updated in flatten()).
I recognize there's some inconsistency here, yeah. Actually, the odd/even rows code in flatten() was misplaced. I've just moved it into finalize(). You're right, it shouldn't work, because it shouldn't rebuild it. I fixed this. It's all tested and in the CVS.
_saveRenderer() and _restoreRenderer() are not used in Mark's example because the $type argument of render() is null.
Wrong. _restoreRenderer is always called (and this is even you that cvs-committed that part ;-)
Indeed, but _restoreRenderer() was supposed to have no effect when saveRenderer() did not get previously called. Thanks for pointing this is_null() oddity in _restoreRenderer(). So to your question : when is init() called ? With a "Direct rendering" driver, which writes directly to standard output, we are forced to call build() everytime render() is called, otherwise, it wouldn't output anything after the first call to render(). But I suppose we thought it was smart to try not to rebuild the datagrid everytime render() is called. Except that, after the first call, options are not taken into account as you point out in this thread... But don't forget one thing : while refactoring the rendering layer (bug #5859), we have had endless discussions about backward compatibility with Structures_DataGrid 0.6.3. Because we're in beta state we must keep BC, as much as we can... So it ends up with complex things that I don't fully understand myself. I appreciate that you review the code the way you do. Thanks -- og

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