Re: Datagrid and linking dataobjects

From: Date: Fri, 21 Jan 2005 22:42:30 +0000
Subject: Re: Datagrid and linking dataobjects
References: 1 2  Groups: php.pear.general 
Request: Send a blank email to pear-general+get-17097@lists.php.net to get a copy of this message
Jamie Alessio wrote:
The snag I ran into with this was that even though the property names of the fields I wanted to display existed in $obj1 (the column names from the join), the DataGrid would not display them. It appears this happened because the fields that were from the joinAdd() were not in my DataObject's fb_fieldsToRender array which is the default value for DataGrid's fields_property. I ended up having to do this in order for DataGrid to actually display the field in the output: /**********************************************/ array_push($dg->_dataSource->_options['fields'], '<yourFieldNameFromTheJoinHere>'); $dg->addColumn(new Structures_DataGrid_Column('<yourLabel>', '<yourFieldNameFromTheJoinHere>', '<yourFieldNameFromTheJoinHere>')); /**********************************************/ There must be a better way to do this, right? I'd like to be able to force Structures_DataGrid to display whatever field I want without having to modify my DataObject. What's the best way to do this? I thought the addColumn() method would take care of it but while it adds the column to the output table it won't bind data to that column unless the field name exists in the $dg->_dataSource->_options['fields'] array.
If I understand your frustrations correctly, I think this is due to the bug in DataObject that referrs to the toArray method. In order for SDG to get your fields, it must "Arrayize" your dataobject, but the toArray method doesn't convert linked columns at the moment. So until that is fixed, SDG will determine your field names based on the binding object. It's a give and take issue, but hopefully it will get fixed soon. Andrew

« previous php.pear.general (#17097) next »