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

Bug #2438 toHTML does not work as expected
Submitted: 2004-10-03 12:54 UTC
From: wiesemann Assigned: asnagy
Status: Closed Package: Structures_DataGrid
PHP Version: Irrelevant OS: Irrelevant
Roadmaps: (Not assigned)    

 [2004-10-03 12:54 UTC] wiesemann
Description: ------------ Calling toHTML() in HTMLTable renderer does not have the same effect as the function render() (expect of the fact, that the first returns the HTML code while the second echos it, of course). Reproduce code: --------------- // using PEAR DB $query = "SELECT * FROM items"; $result = $db->query($query); $dg = new Structures_DataGrid(); while ($row = $result->fetchRow()) { $record = new Structures_DataGrid_Record($row); $dg->addRecord($record); } echo $dg->renderer->toHTML($dg); // using toHTML() directly with echo does not make much sense - it's just done for showing the problem Expected result: ---------------- a HTML table with the contents of the database table Actual result: -------------- no HTML table the problem is: DataGrid/Renderer.php in function render() (line 67): $this->_setDefaultHeaders(); But _setDefaultHeaders() isn't called when using toHTML() as shown above. Now the array columnSet remains empty and the table isn't rendered because of this emptiness. Adding this row: $dg->_setDefaultHeaders(); before echo $dg->renderer->toHTML($dg); solves the problem. (Correct output is generated.) I think this function (marked as private) should be called directly from DataGrid, not from an user script. A comment and/or a fix for this would be nice.


 [2004-10-20 16:06 UTC] asnagy at webitecture dot org
This bug has been fixed in CVS. In case this was a documentation problem, the fix will show up at the end of next Sunday (CET) on In case this was a website problem, the change will show up on the website in short time. Thank you for the report, and for helping us make PEAR better.