Package home | Report new bug | New search | Development Roadmap Status: Open | Feedback | All | Closed Since Version 0.9.3

Request #9566 Get defined columns
Submitted: 2006-12-07 05:25 UTC
From: daniel at assertio dot es Assigned: olivierg
Status: Closed Package: Structures_DataGrid (version 0.7.2)
PHP Version: 5.1.4 OS: Win XP
Roadmaps: (Not assigned)    
Subscription  
Comments Add Comment Add patch


Anyone can comment on a bug. Have a simpler test case? Does it work for you on a different platform? Let us know! Just going to say 'Me too!'? Don't clutter the database with that please !
Your email address:
MUST BE VALID
Solve the problem : 38 - 22 = ?

 
 [2006-12-07 05:25 UTC] daniel at assertio dot es (Daniel Garcia)
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

Comments

 [2006-12-07 20:01 UTC] olivierg at php dot net (Olivier Guilyardi)
Hi Daniel, Can't you do what you need with the getColumnByField() method?
 [2006-12-07 20:09 UTC] wiesemann (Mark Wiesemann)
From my understanding of Daniel's request, he needs more data than he wants to really render. In that case this request would be a duplicate of Bug #7710. @Daniel: If neither Olivier's suggestion nor my hint on Bug #7710 helps you, please clearify what you want to achieve.
 [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 05:45 UTC] wiesemann (Mark Wiesemann)
I haven't got your idea: are you talking about adding a row or about adding a column, or even about adding both of them? Do you want to sum up the values of a single column? Please also tell us which DataSource driver you are using and whether you are using $datagrid->render() (or getOutput()) or $datagrid->fill().
 [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 09:46 UTC] wiesemann (Mark Wiesemann)
Thanks for providing the snapshot. Firstly, the last point in the image is not yet possible ("including those not obtained from the datasource"). We need to find a working and good solution for Bug #7710 first. Secondly, I would suggest that you use fill() instead of getOutput(). With this you could let SDG fill a HTML_Table instance that you created yourself and then add yourself another row (or more rows) with the additional information. This would require knowledge about the columns (and not an automatism for the colspan of the "Total" column), but if the structure does not change often, this would be possible. You could determine the values for the row via array_sum() or array_walk(). Does this help you?
 [2006-12-08 10:30 UTC] olivierg at php dot net (Olivier Guilyardi)
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 10:50 UTC] wiesemann (Mark Wiesemann)
Olivier, > 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). This seems to be a misunderstanding: I agree that the bug has nothing to do with manually created columns. I understood Daniel as if he would want to access data from columns that are not rendered. But maybe he just meant it the way you interpreted it. > 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 ? I have also no objections here if this helps to solve the problem.
 [2006-12-08 12:18 UTC] olivierg at php dot net (Olivier Guilyardi)
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 (Olivier Guilyardi)
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!