How can I make datagrid height is equal to data co

2020-02-12 06:10发布

In adobe Flex datagrid height is equally to fix height . I want to make datagrid height is depend data .

9条回答
一纸荒年 Trace。
2楼-- · 2020-02-12 06:22

I don't quite understand your question but if you are asking how to size the DataGrid to the number of rows in the dataProvider, you can try:

dataGrid.rowCount = yourCollection.length;

or

<mx:DataGrid rowCount="{yourCollection.length}"/>
查看更多
做个烂人
3楼-- · 2020-02-12 06:28

I get the same problem, using Flex SDK 3.3. I've seen several Adobe bug reports over the years regarding this, but the bug checkers always say it's resolved. Best thing I can suggest is to set an explicit pixel height on the datagrid, or you can try this:

dg.height = dg.measureHeightOfItems(0, dgDataProvider.length) + dg.headerHeight;

Bart

查看更多
【Aperson】
4楼-- · 2020-02-12 06:29

Thanks for those saying:

<mx:DataGrid rowCount="{yourCollection.length}"/>

- this actually works for me in Flex 4. However I'd like to point out that according to the documentation "rowCount includes the header row", so I suppose the answer should be

<mx:DataGrid rowCount="{yourCollection.length + 1}"/>

Nevertheless, I think the doco is wrong because the former solution works for me.

Otherwise, does this help? http://www.actionscript.org/forums/showthread.php3?t=220962

查看更多
甜甜的少女心
5楼-- · 2020-02-12 06:32

You can set each row of the datagrid to fit based on the contents of a particular column of that row by setting the "variableRowHeight" attribute to true on the datagrid and setting the "wordWrap" attribute to true on the dataGridColumn that will contain the variable height content.

查看更多
你好瞎i
6楼-- · 2020-02-12 06:35

In Spark DataGrid you can set the requestedRowCount to the dataProviderLength, BUT on condition you Do Not Set a Height for the Datagrid.

Also, for a dataProvider that has a length of less than 3, It'll always show 3 rows.

Note Also Spark offers us requestedMaxRowCount & requestedMinRowCount.

查看更多
来,给爷笑一个
7楼-- · 2020-02-12 06:38

Of course, avoid in your datagrid MXML something like height="100%" or top="10" bottom="123"

查看更多
登录 后发表回答