views:

5107

answers:

10

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

+3  A: 

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.

smartdirt
A: 

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}"/>
cliff.meyers
A: 

Far and away the weirdest problem I've had with Flex is how to simply make Lists and DataGrids size to their contents (not show a scroll bar or any empty rows). I would've thought it would be totally straight forward even with variable row heights. It seems barely anyone else has this problem?!

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

A repeatedly see the above solution - which doesn't work. I get a scroll bar and an extra blank row when there is more than one item in the collection.

I'm having the same problem. Very annoying bug. I use a binding expression on the rowCount and nothing happens. I still get an extra row.
Laxmidi
A: 

Same issue for me too..get a scroll bar and an extra blank row when there is more than one item in the collection.

Any solution?

A: 

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

A: 

Actually the solution works for me (after not being),

I found out that some styles were causing the issue, for me it was fontSize in the Application Style, I was using fontSize: 11;

A: 

Thanks Brat for your answer, that worked for me(in a way). There is just a little modification,when we calculate the height using above calculation a vertical scroll appears, we also need to set verticalScrollPolicy = "off" so that it never shows

Nikhil
A: 

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

eBuildy
A: 

I had the same issue. I set the headerHeight property of the data grid and this fixed the problem.

kenny
A: 

excellent from cliff.meyers solved my problems, thank's. Simple but work

Gus Leo