2

你好,

我想构建一个具有动态高度值的数据网格,因为行数总是不同的。我还想将高度传达回保持它的组件,以便它也随着数据网格一起增长。任何人都可以帮助我找到创建这样一个动态数据网格的最佳方法。

谢谢

4

2 回答 2

1

The DataGrid's height is controlled by its rowCount property. If you want your DataGrid to always be exactly high enough to show all the contained elements (and, for example, wrap it inside a Scroller to handle the situation where the DataGrid is too big for the available space, rather than having the DataGrid itself scroll), simply bind it to an appropriate property of your data source:

<mx:DataGrid dataProvider="{myData}" rowCount="{myData.length}"/>
<fx:Script>
    <![CDATA[
        import mx.collections.ArrayCollection;

        protected var myData:ArrayCollection;
    ]]>
</fx:Script>
于 2011-04-19T23:07:17.657 回答
0

你可以说得更详细点吗?你是说你不希望数据网格滚动吗?如果行数超过屏幕上可以看到的行数怎么办?- 一旦你回答了这些问题,我可以编辑这个更具体的答案。

至于从您的自定义 DataGrid 实现到父对象的通信,您要做的是广播一个指示高度应该改变的事件,并附加一些值 - 行数或新高度,可能 - 到那个事件。

在学习了 Flex 中事件广播的基础知识后,我意识到它们过于复杂,并学习了Swiz 框架,它使事件广播和处理尽可能简单(以及其他一些很棒的东西)。

于 2009-05-18T17:11:23.517 回答