I tried to limit the size of the AdvancedDataGrid to its rows. Currently I am using variableRowHeight to true and at the run time setting the itemRenderer's height.
Hence every row has different height. But I found that the logic behind the calculation of Grid's height is plain and simple - measure the height of the first row, then multiply it with the number of rows. Please correct me if I am wrong here
I did some POC on the issue and found that during the calculateRowHeight event -> it calculates the individual row height but somewhere down the line it is only multiplyin开发者_C百科g the rowCount with the first row's height. Instead it should calculate every row and should sum up the height.
Please suggest a way to overcome this.
PS: I tried below options: 1. rowCount = arrayCollection.length 2. dataGrid.height = dataGrid.measureHeightOfItems(0, arrayCollection.length)+ dataGrid.headerHeight
Best thing you can do is specify the height of the datagrid and the height of each row within it. The whole variable height thing is not consistent.
If you found that the problem is inside this specific method, maybe you can try to extend the AdvancedDataGrid and override the calculateRowHeight method to do this sum.
public class MyAdvancedDatagrid extends AdvancedDataGrid {
override protected function calculateRowHeight(data:Object, hh:Number, skipVisible:Boolean = false):Number {
//Your code here
}
}
The advanced data grid employs the same recycling methodolog of all list in flex. It only creates item renderers for the visual data on the screen. Each and every row found to be non-visible does not have an item renderer created for it, thus the item renderer cannot measure and report a height ot the grid, thus you cannot get the exact height of the grid with variable row height set to true and more data than fits on the screen.
If you want to measure exactly how much height the grid would need, create an item renderer for each row in your data provider, validate and measure it.
The following code can be used in the measure overriden method of the extended AdvancedDataGrid:
override protected function measure():void
{
super.measure();
if(this.dataProvider != null && this.dataProvider.length > 0)
{
this.measuredHeight = this.measureHeightOfItems(0, dataProvider.length);
}
}
This will calculate the height of all the rows and will set the datagrid height accordingly.
精彩评论