6

I have following data:

var data: ArrayCollection = new ArrayCollection(
            [
                { name: "ProductA", user: {login: "loginA", email: "emailA"} },
                { name: "ProductB", user: {login: "loginB", email: "emailB"} },
                { name: "ProductC", user: {login: "loginC", email: "emailC"} }
            ]
        );

This array is a data provider for my AdvancedDataGrid:

<mx:AdvancedDataGrid dataProvider="{data}">
    <mx:columns>
        <mx:AdvancedDataGridColumn headerText="Product" width="55" dataField="name" /> 
        <mx:AdvancedDataGridColumn headerText="User" dataField="user.login" />
        <mx:AdvancedDataGridColumn headerText="Email" dataField="user.email" />
    </mx:columns>
</mx:AdvancedDataGrid>

The problem is - AdvancedDataGrid does not displays properties of nested User object, but the simple DataGrid does. What's wrong here ?

4

2 回答 2

7

您需要使用 labelFunction 或 itemRenderer。这是一个 labelFunction 的例子

<mx:AdvancedDataGridColumn headerText="User" labelFunction="getUserLogin" />

调用

private function getUserLogin(item:Object, column:AdvancedDataGridColumn) {
  return item.user.login;
}

item 参数将是您的单元格正在接收的数据。

于 2010-02-19T22:20:38.347 回答
1

DataGrid 被修补以支持复杂的路径,但我不认为 AdvancedDataGrid 是。更多详细信息: http: //bugs.adobe.com/jira/browse/SDK-9801

您可以改用 labelFunction。

于 2010-02-19T22:19:45.603 回答