PEAR is archived and read-only

This mirror preserves historical PEAR package releases and metadata so existing references remain available.

Home » Structures » Structures_DataGrid » Bug #9566

Get defined columns

Details

Request #9566Get defined columns
Submitted2006-12-07 05:25 UTC
Fromdaniel at assertio dot es
Assignedolivierg
StatusClosed
PackageStructures_DataGrid
PHP Version5.1.4
OSWin XP
Roadmaps(Not assigned)

Comments

[2006-12-07 05:25 UTC] daniel at assertio dot es

Description:
------------
Hello,

In order to customize the datagrid output, I need to access the defined column set but I cannot find the proper method in DataGrid or in the concrete renderer container (HTML_Table). I need the full column set, not only the DataSource's, so I guess using DataSouce::getColumns is not useful. Besides, I see property columnSet access is marked as private.

Thanks for taking the time to read this, best wishes
- Dani

[2006-12-07 20:01 UTC] olivierg at php dot net

Hi Daniel,

Can't you do what you need with the getColumnByField() method?

[2006-12-08 04:46 UTC] daniel at assertio dot es

I try to explain what I want to archieve, it may make my need clearer:
Initially I have a datagrid resembling a DB table with some custom-formatted columns (for example
Edit | Delete | Order # | Description | Quantity | Ammount.
No problem.
Then I need to add a Totals row: My idea was to integrate that totals row in the datagrid, but for the totals I only need to sum the Quantity and Ammount cols. Then what I want is to use the HTML_Table object to merge the initial descriptive columns into a single column reading "TOTAL", and render the summed columns behind the corresponding column.
In order to do that, I thought of looping the columnSet defined in the DataGrid object to retrieve the position of each column and then calculate the colspan.
(BTW, in my opinion the idea of separating fetched columns from rendered columns (Bug #7710) would be very handy and help make DG structure clearer.)
TIA
- Dani

[2006-12-08 08:43 UTC] daniel at assertio dot es

Actually, I'm adding a row. Since it's a bit tiring to try to explain it, you can find a snapshot of what's my goal at http://www.quintopino.com/misc/customRow.png (in fact, I made that customization accessing directly the DataGrid->columnSet "private" property). I hope that's more explicit.

DataSource is an array, and the table is rendered using DataGrid->getOutput(). I don't use DataGrid->fill().

TIA
- Dani

[2006-12-08 10:30 UTC] olivierg at php dot net

Mark, bug #7710 does not forbid retrieving informations from the columns that were manually created by the user (== "not obtained from the datasource", if I understand correctly).

Daniel, I second Mark about using fill(). That should be quite handy in your case.

Concerning your specific problem, it's a little complex, and there certainly are many ways to solve it. However, if you think that a generic SDG::getColumns() method would help you, I see no objection for it and might add it. Should we simply go this path ?

[2006-12-08 12:18 UTC] olivierg at php dot net

Okay, I've added Structures_DataGrid::getColumns() in CVS. However, due to a small bug related to the new streaming future we are developing, you need to call this method after rendering.

If you call it after bind() but before rendering you might observe unexpected results. But this should be fixed in the next release.

If there's no objection I propose we close this bug.

[2006-12-08 16:59 UTC] olivierg at php dot net

Okay, so I just fixed this small bug: you can use getColumns() after binding and before rendering. It should work fine from now. It's all in CVS. I close this bug.

Thanks for your report

[2006-12-09 04:37 UTC] daniel at assertio dot es

I take note of using fill() for customizations, that definitely seems the way to go.
I do appreciate your prompt support and action. Thank you!