Re: Re: Structures_DataGrid_Renderer_Smarty
| From: | Olivier Guilyardi | Date: | Fri, 20 Oct 2006 21:13:36 +0000 |
| Subject: | Re: Re: Structures_DataGrid_Renderer_Smarty | ||
| References: | 1 2 3 4 5 6 | Groups: | php.pear.general |
| Request: | Send a blank email to pear-general+get-25579@lists.php.net to get a copy of this message | ||
Hi Mark and Chris,
Mark Wiesemann a écrit :
> Chris Boget wrote:
>> If I didn't want to display the column headers and/or if I wanted to
>> explicitely
>> position this column here and that column there, I'm not going to be
>> working
>> with the $columnSet at all.
>>
>> What I have to do now is access each column like:
>>
>> {$recordSet[row][0]} or {$recordSet[row][1]}
>>
>> which isn't all that big of a deal. But that assumes that the in
>> which the
>> fields are selected do not change and that the actual columns selected
>> do not change. Do you see where I'm going here?
What I understand is that you want to change the order of columns and/or select
which columns to show.
> Yes, I see the problem. I'll send a copy of this mail to Olivier
> Guilyardi. He is the one who developed the Smarty renderer (not sure if
> he did the inital version, but he worked very much on it) and knows
> better why the design of the renderer is how it is.
First of all, please consider that Structures_DataGrid follows the MVC pattern:
- Core = Controller
- DataSource = Model
- Renderer = View
In the current design of Structures_DataGrid, changing the order of columns (or
selecting which ones to show), is, like changing the order of records (or
filtering them), considered to be a matter of changing _content_, not
_presentation_.
In this regard, it is out of the scope of the Rendering layer, and therefore not
the job of the Smarty driver.
So to change the order of columns and/or the ones to show, you need to change
the way you retrieve data, not the way you display it. Example :
$options = array('fields' => array('name', 'stock',
'price'));
or
$options = array('fields' => array('stock' , 'name',
'price', 'description'));
and then:
$datagrid->bind($container, $options);
You could alternatively use addColumn().
Regards,
--
Olivier