Re: Structures_DataGrid: Columns for fields missing in first record?
| From: | Markus Ernst | Date: | Wed, 05 Jul 2006 15:34:06 +0000 |
| Subject: | Re: Structures_DataGrid: Columns for fields missing in first record? | ||
| References: | 1 2 | Groups: | php.pear.general |
| Request: | Send a blank email to pear-general+get-24565@lists.php.net to get a copy of this message | ||
Mark Wiesemann schrieb:
This helps, thank you! As the input source is an array, and the columns are not known before runtime, I chose to go the other way around: extract the column names separately when creating the source array, and add the missing ones to the first record before bind()ing :-) -- MarkusI 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:You're right. If you don't specify any column, we look into the first record to auto-detect the columns -- this was done for effiency reasons. The best solution would be to use addColumn() which also allows to give more meaningful column headers than just the array keys.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.It is appropriate, but looping through all records can be too expensive for large recordsets (just think of a not paged CSV output with 1 million records ...).