如何将 AdvancedDataGrid 的大小限制为具有可变行高的行

发布于 2024-12-01 15:02:53 字数 473 浏览 0 评论 0原文

我尝试将 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

以为你会在 2024-12-08 15:02:53

您可以做的最好的事情是指定数据网格的高度以及其中每行的高度。整个可变高度的事情并不一致。

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.

何时共饮酒 2024-12-08 15:02:53

如果您发现问题出在这个特定方法内,也许您可​​以尝试扩展 AdvancedDataGrid 并重写calculateRowHeight 方法来执行此求和。

public class MyAdvancedDatagrid extends AdvancedDataGrid {

    override protected function calculateRowHeight(data:Object, hh:Number, skipVisible:Boolean = false):Number {
     //Your code here
    }

}

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
    }

}
苍景流年 2024-12-08 15:02:53

高级数据网格采用与 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.

毁梦 2024-12-08 15:02:53

以下代码可用于扩展 AdvancedDataGrid 的度量覆盖方法:

override protected function measure():void
{
    super.measure();
    if(this.dataProvider != null && this.dataProvider.length > 0)
    {
        this.measuredHeight = this.measureHeightOfItems(0, dataProvider.length);
    }
}

这将计算所有行的高度并相应地设置数据网格高度。

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文