We'll probably just keep pointing people to the example on my blog. There dataField is checked quite often during initial rendering and scrolling and we don't want to do any extra thinking looking for dot-paths unless you know you're going to need it.
________________________________ From: [email protected] [mailto:[EMAIL PROTECTED] On Behalf Of André Rodrigues Pena Sent: Monday, May 28, 2007 7:17 AM To: [email protected] Subject: Re: [flexcoders] DataGrid and complex types Of course this helped Andrea. Thanks. I think Adobe should think of allowing the dataField attribute to work with properties of Objects On 5/27/07, Andrea Santambrogio <[EMAIL PROTECTED] <mailto:[EMAIL PROTECTED]> > wrote: On 27/05/2007, at 21:57, André Rodrigues Pena wrote: Although when I try to populate de DataGrid, I can't set a DataGridColumn to display the property "name" within the property "product" from the data provider. The code is the following: <mx:DataGrid id="datagrid" dataProvider="{sales}" width="100%" height="100% "> <mx:columns> <mx:DataGridColumn dataField="id" headerText="Id"/> <mx:DataGridColumn dataField="product.name" headerText=" Product"/> <mx:DataGridColumn dataField="customer .name" headerText="Customer" /> </mx:columns> </mx:DataGrid> Only the simple attribute "id" is properly displayed in the DataGrid Why? What can I do? . The way I solved it was by using a custom label function for each column. Instead of specifying a dataField, you define the following function inside a script tag: function myCustomDataLabelFunction(item:Object, column:DataGridColumn):String { return item.product.name <http://item.product.name> ; } Then you declare the column like this: <mx:DataGridColumn labelFunction="myCustomDataLabelFunction" headerText="Product"/> Basically, your label function gets invoked on each item, when the column needs to know what to display on that row. And you have to return the value you want to be displayed. I hope this helped, Andrea. -- André Rodrigues Pena LOCUS www.locus.com.br <http://www.locus.com.br> Blog www.techbreak.org <http://www.techbreak.org>

