使用固定 rowCount 和 rowCount 来缩放 Spark DataGrid没有斯科勒斯
我正在尝试找到一种方法来缩放(字体或scaleX&Y)DataGrid(使用requestedMinRowCount = requestsMaxRowCount = requestsRowCount = dataProviderLength),以便它始终显示所有内容行(所以没有滚动条)。
我提出的缩放解决方案是:
protected function thisDatagrid_resizeHandler(event:ResizeEvent):void
{
if (event.oldWidth < this.width) {
this.setStyle('fontSize', this.getStyle('fontSize') + 0.5);
} else if (event.oldWidth > this.width) {
this.setStyle('fontSize', this.getStyle('fontSize') - 0.5);
}
this.minWidth = this.measuredMinWidth;
}
虽然上面的代码实际上在调整大小时调整了文本(因此是单元格、列和网格)的大小,但我遇到的问题是当重新缩放垂直发生时。
为了使 requestsRowCount 正常工作,Datagrid 上不应设置固定高度。 所以我想知道有什么方法可以让网格不断显示所有的行和行?缩放时的列(即使垂直调整大小)?
另一个选项是覆盖 updateDisplayList,尽管不能直接调整大小。
override protected function updateDisplayList(unscaledWidth:Number, unscaledHeight:Number):void {
//super.updateDisplayList(unscaledWidth, unscaledHeight);
trace('oldWidth: ' + oldWidth + ' | unscaledWidth: ' + unscaledWidth + ' | parentWidth: ' + this.parent.width);
trace('oldHeight: ' + oldHeight + ' | unscaledHeight: ' + unscaledHeight + ' | parentHeight: ' + this.parent.height);
trace('Potential ScaleX: ' + (unscaledWidth - oldWidth)/unscaledWidth);
trace('Potential ScaleY: ' + (unscaledHeight - oldHeight)/unscaledHeight);
trace('----------------------------------------------------');
/* scaleX = (unscaledWidth - oldWidth)/unscaledWidth;
scaleY = (unscaledHeight - oldHeight)/unscaledHeight; */
//super.updateDisplayList(unscaledWidth, unscaledHeight);
}
如果我取消注释scaleX & 就会出现问题scaleY,它会永远循环...
I am trying to find a way to Scale (either font or scaleX&Y) a DataGrid (with requestedMinRowCount = requestedMaxRowCount = requestedRowCount = dataProviderLength), so that it would Always show all the Rows (so no scrollers).
A Solution I came up with for Scaling is:
protected function thisDatagrid_resizeHandler(event:ResizeEvent):void
{
if (event.oldWidth < this.width) {
this.setStyle('fontSize', this.getStyle('fontSize') + 0.5);
} else if (event.oldWidth > this.width) {
this.setStyle('fontSize', this.getStyle('fontSize') - 0.5);
}
this.minWidth = this.measuredMinWidth;
}
While the code above actually does resize the text (hence the cell, column and grid) on Resize, the problem I am getting is when the rescale happens vertically.
For the requestedRowCount to work, there should not be a fixed height set on the Datagrid.
So I am wondering what is the way to get the grid to constantly show all it's rows & columns as it scales (even if resized vertically)?
Another Option would be overriding updateDisplayList, though not straight forward for resizing.
override protected function updateDisplayList(unscaledWidth:Number, unscaledHeight:Number):void {
//super.updateDisplayList(unscaledWidth, unscaledHeight);
trace('oldWidth: ' + oldWidth + ' | unscaledWidth: ' + unscaledWidth + ' | parentWidth: ' + this.parent.width);
trace('oldHeight: ' + oldHeight + ' | unscaledHeight: ' + unscaledHeight + ' | parentHeight: ' + this.parent.height);
trace('Potential ScaleX: ' + (unscaledWidth - oldWidth)/unscaledWidth);
trace('Potential ScaleY: ' + (unscaledHeight - oldHeight)/unscaledHeight);
trace('----------------------------------------------------');
/* scaleX = (unscaledWidth - oldWidth)/unscaledWidth;
scaleY = (unscaledHeight - oldHeight)/unscaledHeight; */
//super.updateDisplayList(unscaledWidth, unscaledHeight);
}
The problem with this if I uncomment scaleX & scaleY, it'll loop forever...
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我可能会误解你,但你不能使用:
I might be misunderstanding you but couldn't you just use:
最好的(也是最高效的方法是使用数据网格所在的组的布局,并应用如下所示的布局:
例如:ScaleOneLayout.as
import mx.core.UIComponent;
The best (and most performant way is to use the layout of a group where the Datagrids would be located, and apply a layout like the one below:
ex: ScaleOneLayout.as
import mx.core.UIComponent;