Flex DataGrid列宽 [英] Flex DataGrid Column Width

查看:171
本文介绍了Flex DataGrid列宽的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我的flex应用程序中,我将列的宽度和可见性存储在xml文件中。当应用程序加载时,它从xml文件读取并设置他的列值适用:

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:

for(i = 0; i < columnsOrder.length; i++){
    newOrder[i] = myDG.columns[Number(columnsOrder[i]) - 1];
    newOrder[i].visible = (Number(columnsVisiblity[i]) == 1);
    newOrder[i].width = Number(columnsWidth[i]);
}
myDG.columns = newOrder;
myDG.invalidateList();

问题似乎是设置可见性(它正确设置可见字段,但会混淆宽度) ...在设置宽度(循环外)和循环之前,我已经尝试设置了它。

The problem appears to be setting the visibility (it sets the visible field correctly but messes up the width)... I've tried setting it after setting the width (outside of the loop) and before the loop as well. It resizes the columns properly if I don't do anything with the visibility.

任何想法?

推荐答案

在类文件的顶部添加一个import语句:

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

import mx.core.mx_internal;

import mx.core.mx_internal;

然后使用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)

这篇关于Flex DataGrid列宽的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆