Structures_DataGrid: Columns for fields missing in first record?
| From: | Markus Ernst | Date: | Wed, 05 Jul 2006 08:59:56 +0000 |
| Subject: | Structures_DataGrid: Columns for fields missing in first record? | ||
| Groups: | php.pear.general | ||
| Request: | Send a blank email to pear-general+get-24559@lists.php.net to get a copy of this message | ||
Hi
I encountered that if the records of the datasource do not have a unique set of fields, the columns are only taken from the first record:
$data = array(
array('name' => 'Mark', 'email' => 'mark@xyz.com', 'age' => '90'),
array('name' => 'Helen', 'age' => '40'),
);
$datagrid =& new Structures_DataGrid();
$datagrid->bind($data);
$datagrid->render(DATAGRID_RENDER_CONSOLE);
outputs:
+-------+--------------+-----+
| name | email | age |+-------+--------------+-----+ | Mark | mark@xyz.com | 90 |
| Helen | | 40 |+-------+--------------+-----+ If the source is changed to: $data = array(
array('name' => 'Helen', 'age' => '40'),
array('name' => 'Mark', 'email' => 'mark@xyz.com', 'age' => '90'),
);
the email column is missing:
+-------+-----+
| name | age |
+-------+-----+
| Helen | 40 |
| Mark | 90 |
+-------+-----+
I did not find an option to change this behaviour; now I wonder if I missed something, or if this should be subject to a feature request, or if this kind of source structure is just not considered to be appropriate.
Thanks
Markus