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 #3523

Allow custom headers ahead of header row

Details

Request #3523Allow custom headers ahead of header row
Submitted2005-02-19 00:28 UTC
Fromjessup at mrpath dot com
Assignedolivierg
StatusClosed
PackageStructures_DataGrid
PHP VersionIrrelevant
OSN/A
Roadmaps(Not assigned)

Comments

[2005-02-19 00:28 UTC] jessup at mrpath dot com

Description:
------------
Here are the changes I made to fix this.

The changes and line numbers are relative to Structures_DataGrid/DataGrid/Renderer/HTMLTable.php version 1.40:

Insert between lines 308 and 309:
if (!is_array($this->_dg->columnSet) or count($this->_dg->columnSet) < 1) {
return;
}
$row = $this->_table->addRow();

Lines 378-379 Old:
$this->_table->setHeaderContents(0, $cnt, $str);
$this->_table->setCellAttributes(0, $cnt, $column->attribs);

Lines 378-379 New:
$this->_table->setHeaderContents($row, $cnt, $str);
$this->_table->setCellAttributes($row, $cnt, $column->attribs);

Lines 417-421 Old:
// Begin loop
$rowCnt = 0;
for ($i = $begin; $i < $end; $i++) {
if (isset($this->_dg->recordSet[$i])) {
$rowCnt++;
$cnt = 0;

Lines 417-421 New:
// Begin loop
for ($i = $begin; $i < $end; $i++) {
if (isset($this->_dg->recordSet[$i])) {
$rowCnt = $this->_table->addRow();
$cnt = 0;

Expected result:
----------------
I want to be able to manually call $dg->renderer->_table->addRow() without having the row overwritten by $dg->render();

[2005-03-08 20:48 UTC] jason at greenhell dot com

I second this feature request.

In my project, we are needed to implement "Table Filters". This means having a small select drop-down at the top of each column, allowing the user to filter the table data by a selected filter.

We chose to use DataStructures_DataGrid because it is very handy and well designed. However, the ability to customize the table grid *after* the datasource has been bound is an important one.

Please consider this ability in your design for the PHP5 version. All in all, great work on this library!

[2005-05-22 00:46 UTC] jessup at mrpath dot com

That could work for Jason's situation, but it does nothing for mine. I'm using headers that consume more than one row. If you want to see an example of what I'm aiming for, look at http://www.squaredealonline.com/b.asp?v=3
It's not in php, but it will be when I'm done.

I'm actually surprised that you had any resistance to the original changes. It breaks nothing, it has no appreciable speed decrease, and it makes the object less likely to break if new features are added (such as setHeader or setFooter functions which would require changes along these lines anyways).

[2006-03-02 01:24 UTC] olivierg at php dot net

Thank you for this report. We have been working a lot on the renderer layer (see Bug #5859) and this bug is now fixed in CVS.

A new method called fill() allows for great flexibility.

Here is a simplified example to achieve what you need :

$table = new HTML_Table();
$header =& $table->getHeader();
$header->setHeaderContents(0,0,"Some data");
$header->setHeaderContents(0,1,"More data");
[...]

$datagrid->fill($table);

This will append the datagrid headers and body to your custom headers, without overwriting them.

Best regards