English 中文(简体)
Flex 4, 高级DataGrid: 初始列宽度
原标题:Flex 4, AdvancedDataGrid: initial column width

I got a problem with the widths of the advanceddatagrid-columns. 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.

左左侧:导航

右右侧: 模块 (例如, 高级数据格)

多数列的宽度是固定的, 有些是微小的边框。 现在, 最初列的宽度是正确的 。

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. Neither the fixed widths nor the minWidths are initially correct. 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();

总的来说,这只是滚动政策的一个暂时改变, 重新设置柱形, 然后又回移。但是,它仍然有效。

有谁知道吗?

问题回答

可能有所帮助的一些相关提法(对我有用的第一个提法):

http://userflex.wordpress.com/2011/04/14/force-resize-datagrid/

http://forums.adobe.com/message/4285461

总结第一篇文章(信用归尼克·施内布勒):

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;
    } 
}

但只要数据网中的基本数据发生改变, 你就会有美丽的柱子。





相关问题
Disable button tooltip in AS3

I want to disable the tooltip on certain buttons. The tooltip manager seems to be an all or nothing solution. Is it possible to disable the tooltip for just one or two buttons?

Multiple Remote call made simultenously

I was making multiple remote calls and they are done sequentially and when I am getting a result event back it s triggering calls to all the methods with ResultEvent as an argument . I am supposed to ...

Attaching a property to an event in Flex/AS3

I have a parameter that needs to be passed along with an event. After unsuccessful attempts to place it on the type by extending the class, I ve been advised in another SO question to write a custom ...

Clearing RSL in Cache

I have built a flex application which has a "main" project and it is assosciated with a few RSL s which are loaded and cached once i run my "main" application. The problem i am facing is that the ...

What s a good way of deserializing data into mock objects?

I m writing a mock backend service for my flex application. Because I will likely need to add/edit/modify the mock data over time, I d prefer not to generate the data in code like this: var mockData =...

AS3 try/catch out of memory

I m loading a few huge images on my flex/as3 app, but I can t manage to catch the error when the flash player runs out of memory. Here is the what I was thinking might work (I use ???? because i dont ...

热门标签