You'll need to use a labelFunction for nested fields in a DataGrid, the
DataGrid cannot walk through nested objects for the dataField.

 

Matt

 

________________________________

From: [email protected] [mailto:[EMAIL PROTECTED] On
Behalf Of dzeitman
Sent: Saturday, November 25, 2006 8:39 AM
To: [email protected]
Subject: [flexcoders] Data binding nested data??? BUG???

 

All,
Does anyone understand why this databinding doesn't work. It seems 
like this is a significant bug.

Example shows a form with several fields, a data model, bindings, a 
grid and a second form to echo the data. Clearly the bindings work 
as the second form echos the first, the top level objects, email and 
description also work, it's the nested objects that don't work on the 
grid.

This the datagrid does work as I would I would expect:

Any thoughts would be appreciated.

<!-- Example-->

<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml
<http://www.adobe.com/2006/mxml> " 
layout="absolute">


<!-- Form contains user input controls. -->
<mx:Form label="Employee Information">
<mx:FormItem label="First Name">
<mx:TextInput id="firstName"/>
</mx:FormItem>
<mx:FormItem label="Last Name">
<mx:TextInput id="lastName"/>
</mx:FormItem>
<mx:FormItem label="Department">
<mx:TextInput id="department"/>
</mx:FormItem>
<mx:FormItem label="Email Address">
<mx:TextInput id="email"/>
</mx:FormItem>
</mx:Form>

<!-- The myEmployee data model. -->
<mx:Model id="myEmployee">
<Employee>
<name>
<first/>
<last/>
</name>
<department/>
<email/>
</Employee>
</mx:Model>

<mx:Binding source="firstName.text" 
destination="myEmployee.name.first"/>
<mx:Binding source="lastName.text" 
destination="myEmployee.name.last"/>
<mx:Binding source="department.text" 
destination="myEmployee.department"/>
<mx:Binding source="email.text" destination="myEmployee.email"/>

<mx:DataGrid x="394" y="0" dataProvider="{myEmployee}">
<mx:columns>
<mx:DataGridColumn headerText="First Name" 
dataField="name.first"/>
<mx:DataGridColumn headerText="Last Name" 
dataField="name.last"/>
<mx:DataGridColumn headerText="Department" 
dataField="department"/>
<mx:DataGridColumn headerText="Email" 
dataField="email"/>
</mx:columns>
</mx:DataGrid>
<mx:Form label="Employee Information Echo" x="10" y="156">
<mx:FormItem label="First Name">
<mx:TextInput text="{myEmployee.name.first}"/>
</mx:FormItem>
<mx:FormItem label="Last Name">
<mx:TextInput text="{myEmployee.name.last}"/>
</mx:FormItem>
<mx:FormItem label="Department">
<mx:TextInput text="{myEmployee.department}"/>
</mx:FormItem>
<mx:FormItem label="Email Address">
<mx:TextInput text="{myEmployee.email}"/>
</mx:FormItem>
</mx:Form>

</mx:Application>

 

Reply via email to