如何将 AdvancedDataGrid 的大小限制为具有可变行高的行
我尝试将 AdvancedDataGrid 的大小限制为其行。目前我使用variableRowHeight为true并在运行时设置itemRenderer的高度。
因此,每一行都有不同的高度。但我发现网格高度计算背后的逻辑简单明了——测量第一行的高度,然后将其乘以行数。 如果我错了,请纠正我
我对这个问题做了一些POC,发现在calculateRowHeight事件期间 ->它计算单个行的高度,但在该行的某个地方,它仅将 rowCount 与第一行的高度相乘。相反,它应该计算每一行并总结高度。
请建议一种方法来克服这个问题。
PS:我尝试了以下选项: 1. rowCount = arrayCollection.length 2. dataGrid.height = dataGrid.measureHeightOfItems(0, arrayCollection.length)+ dataGrid.headerHeight
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 multiplying 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
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
您可以做的最好的事情是指定数据网格的高度以及其中每行的高度。整个可变高度的事情并不一致。
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.
如果您发现问题出在这个特定方法内,也许您可以尝试扩展 AdvancedDataGrid 并重写calculateRowHeight 方法来执行此求和。
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.
高级数据网格采用与 Flex 中所有列表相同的回收方法。它仅为屏幕上的视觉数据创建项目渲染器。发现不可见的每一行都没有为其创建项目渲染器,因此项目渲染器无法测量和报告网格的高度,因此您无法将可变行高设置为的网格的准确高度真实且数据超出屏幕显示范围。
如果您想准确测量网格需要多少高度,请为数据提供程序中的每一行创建一个项目渲染器,对其进行验证和测量。
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.
以下代码可用于扩展 AdvancedDataGrid 的度量覆盖方法:
这将计算所有行的高度并相应地设置数据网格高度。
The following code can be used in the measure overriden method of the extended AdvancedDataGrid:
This will calculate the height of all the rows and will set the datagrid height accordingly.