无法动态地改变弹性数据网格的列宽 [英] Unable to change the column width dynamically in flex datagrid

查看:139
本文介绍了无法动态地改变弹性数据网格的列宽的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这是非常非常令人沮丧。我使用的是单例类(弹出,这意味着它不会忘了上次使用的变量),其中包含一个数据网格。我想提出各列显示/隐藏,设置宽度和头部根据从数据库调用接收到的数据。一切正常,只是在我面前把断点,并在那里我改变宽度的列后点,我没有看到数据网格的宽度在所有的变化!相反,我看到一些价值观完全不同步的宽度DataGrid列的!但是,由于它是一个单例类,下一次我把这个弹出窗口中,我看到的宽度,我也设立在最后一次通话。

It's very very frustrating. I am using a singleton class (popup, which means it doesn't forget the last used variables) which contains a datagrid. I am making various columns visible/invisible, setting the widths and headers in accordance to data received from a database call. Everything works fine except that when I put the breakpoints before and after the point where I change width of columns, I do not see the change in width of datagrid at all! Instead I see some values totally out of sync as widths of datagrid column! However, since it is a singleton class, the next time I call this popup, I see widths which I did set up in last call.

我一定要搞乱在调用setWidth()函数(这是我的自定义函数,它改变了数据网格的宽度动作脚本)。应该是什么的地步,我必须调用这个函数?我想在的creationComplete,显示和数据提供器的二传手。没有帮助...

I must be messing up in calling the setWidth() function (which is my custom function which changes the width of datagrid in action script). What should be the point where I should call this function? I tried in creationComplete, show and in the setter of dataprovider. Doesn't help...

我一直水平滚动政策'关闭'(完全弄乱它打开它)。

I have kept horizontal scroll policy as 'off' (turning it on totally messes it up).

如果我这样做datagrid.validateNow(),它并不能帮助!为什么地狱我看不到的宽度变化立即反映出来,如果​​我把断点前后的变化之后。有人请告诉我什么,我做错了。

If I do datagrid.validateNow(), it doesn't help! And why the hell I don't see the width change reflected immediately if I put the breakpoints before and after the change. Somebody please advise me about what I am doing wrong here.

感谢。

推荐答案

首先要表示自己什么可能是错在这里。对

First of all you are indicating yourself what might be wrong here.

1)当你更新的宽度,当组件可见=>没有改变

1) When you update the width when the component is visible => no change

2)当您关闭弹出窗口并重新打开这个它是确定,这也意味着该项目已被重新呈现,而这已经不是第一次。这意味着,你确实要尝试并触发这个自己。

2) When you close the popup and reopen this it is ok, this also means that the item has been re-rendered whereas it was not the first time. This means that you indeed have to try and trigger this yourself.

下面是关于Flex组件生命周期的某些有用的链接。这些应该帮助你找出要调用哪些方法和/或覆盖。

Here are some usefull links concerning flex component lifecycle. These should help you figure out which methods to call and / or override.

http://weblog.mrinalwadhwa.com/2009 / 06/21 /柔性-4-组件的生命周期/

http://www.slideshare.net/rjowen /土坯柔性组件的生命周期,presentation

此外,你应该永远不会调用validateNow()直接,而是使用失效的方法来代替。

Furthermore, you should never call validateNow() directly, but use invalidation methods instead.

我想在这种情况下,你需要触发组件的测量,以便调用 invalidateSize()应该做的就好了。

I guess in this case you need to trigger the measurement of your component so a call to invalidateSize() should do just fine.

干杯

这篇关于无法动态地改变弹性数据网格的列宽的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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