开发者

AdvancedDataGrid does not displays object properties

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:colu开发者_Go百科mns>
        <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 ?


You need to use a labelFunction or an itemRenderer. Here is an example of a labelFunction

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

which calls

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

The item argument will be the data that your cell is receiving.


DataGrid was patched to support complex paths but I don't think that AdvancedDataGrid was. More details: http://bugs.adobe.com/jira/browse/SDK-9801

You can use a labelFunction instead.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜