Flex DataGrid Column Width

前端 未结 3 927
臣服心动
臣服心动 2021-01-07 07:30

In my flex app I store the widths and visiblility of columns in an xml file. When the app loads it reads from the xml file and sets he columns values as applicable:

相关标签:
3条回答
  • 2021-01-07 07:59

    Is you horizontalScrollPolicy set to false on the datagrid?

    "If the DataGrid's horizontalScrollPolicy property is false, all visible columns must fit in the displayable area, and the DataGrid will not always honor the width of the columns if the total width of the columns is too small or too large for the displayable area."

    http://livedocs.adobe.com/flex/3/langref/mx/controls/dataGridClasses/DataGridColumn.html#width

    0 讨论(0)
  • 2021-01-07 08:04

    Add an import statement at the top of your class file:

    import mx.core.mx_internal;

    Then remove using the mx_internal namespace, remove the owner of the column, change the width and then reasign the parent:

    public static function resizeColumn(col:DataGridColumn, size:int):void
        {
            var owner:* = col.mx_internal::owner
            col.mx_internal::owner = null;
    
            col.width = size;
    
            col.mx_internal::owner = owner;
        }
    

    This ought to do the trick (well, it did for us after a couple of days of swearing)

    0 讨论(0)
  • 2021-01-07 08:15

    I was able to get it to work by calling the above loop in a function twice... the first time it add the visible columns, the second time it sets the correct width. Not the best solution but I cannot spend any more time on it.

    0 讨论(0)
提交回复
热议问题