[英]Flex 4, AdvancedDataGrid: initial column width
I got a problem with the widths of the advanceddatagrid-columns. 我对advanceddatagrid列的宽度有疑问。 First of all, my layout is a HDividedBox, on the left there is the navigation, on the right there is a module, containing the advanceddatagrid. 首先,我的布局是HDividedBox,左边是导航,右边是一个模块,其中包含advanceddatagrid。
left Side: navigation 左侧:导航
right side: module (eg advanceddatagrid) 右侧:模块(例如advanceddatagrid)
Most of the columns got a fixed width, some a minWidth. 大多数列的宽度都是固定的,有些是minWidth。 Now, initially the widths of the columns are correct. 现在,最初列的宽度是正确的。
So the problem is, whenever I load a new module and later reload the advanceddatagrid, the initial width of the columns is way different, although I change nothing in the process of loading the module. 因此,问题是,尽管我在加载模块的过程中未进行任何更改,但每次加载新模块并随后重新加载advanceddatagrid时,列的初始宽度都大不相同。 Neither the fixed widths nor the minWidths are initially correct. 固定宽度和minWidths最初都不正确。 I recently saw there is a solution for wrong widths of colums, it looks like that: 我最近看到了一种针对错误宽度的解决方案,看起来像这样:
var oldPolicy:String = advanceddatagrid.myScrollPolicy;
advanceddatagrid.myScrollPolicy = ScrollPolicy.ON;
for(var i:int = 0; i < advanceddatagrid.columns.length; i++) {
var column:AdvancedDataGridColumn = advanceddatagrid.columns[i] as AdvancedDataGridColumn;
advanceddatagrid.column.width = column.width;
}
advanceddatagrid.validateNow();
advanceddatagrid.myScrollPolicy = oldPolicy;
advanceddatagrid.validateNow();
On the whole this is just a temporary change of the ScrollPolicy, re-setting the column-widths and then changing back. 总体而言,这只是ScrollPolicy的临时更改,需要重新设置列宽然后再更改。 But still, it doenst work. 但是,它确实起作用。
Does anyone have a clue? 有人有线索吗?
Some relevant references that might help (the first one worked for me): 一些可能有用的相关参考(第一个对我有用):
http://userflex.wordpress.com/2011/04/14/force-resize-datagrid/ http://userflex.wordpress.com/2011/04/14/force-resize-datagrid/
http://forums.adobe.com/message/4285461 http://forums.adobe.com/message/4285461
To summarize the first post (credit goes to Nick Schneble): 总结第一篇文章(版权归Nick Schneble所有):
public function resizeColumns () : void
{
grid.validateNow ();
// forces the columns to size themselves properly
for each (var column : AdvancedDataGridColumn in grid.columns)
{
column.width = column.width;
}
}
It may seem a bit ridiculous, but if you execute this method whenever the underlying data in your data grid changes, you'll have beautifully laid out columns. 看起来有些荒谬,但是如果每当数据网格中的基础数据发生更改时就执行此方法,则列的布局会很漂亮。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.