【问题标题】:Flex datagrid component and aggregated classesFlex 数据网格组件和聚合类
【发布时间】:2010-12-20 01:28:24
【问题描述】:

我有以下关于 Flex/AIR 数据网格的问题:

我可以将一个聚合对象的 var 值作为 DataGrid 列的 dataField 访问吗?

我想要的是:

public class A { public var id:String; }

public class B { public var a:A; public var value:uint; }

    <mx:DataGrid id="grid" dataProvider="{items}">
        <mx:columns>
            <mx:DataGridColumn headerText="aId" dataField="a.id"/>
            <mx:DataGridColumn headerText="value" dataField="value"/>
        </mx:columns>
    </mx:DataGrid>

items 是 B 的 ArrayCollections。

根据我已阅读并查看 DataGridColumn 的代码,此“a.id”不起作用,因为该值是使用数组语法 data[key] 从数据对象中获取的,我尝试使用自定义项目渲染器,但这也不起作用。

我能得到一些帮助吗?我正在尝试将 Flex 确定为家庭项目,而我刚刚开始。

【问题讨论】:

  • 我还做的是为 id 字段添加 setter 和 getter 函数,但这不适用于大类层次结构。

标签: apache-flex datagrid air


【解决方案1】:

经过多次尝试,问题解决了。

<mx:DataGrid id="grid" dataProvider="{items}">
    <mx:columns>
        <mx:DataGridColumn headerText="aId">
            <mx:itemRenderer>
                <mx:Component>
                    <mx:Label text="{data.a.id}"/>
                </mx:Component>
            </mx:itemRenderer>
        </mx:DataGridColumn>
        <mx:DataGridColumn headerText="value" dataField="value"/>
    </mx:columns>
</mx:DataGrid>

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2010-12-22
    • 2011-07-23
    • 2011-10-21
    • 1970-01-01
    • 1970-01-01
    • 2014-08-20
    • 1970-01-01
    • 2014-05-07
    相关资源
    最近更新 更多