如何获取Flex 3 ComboBox宽度根据绑定数据进行调整提供者内容有变化? [英] How to get Flex 3 ComboBox width to adjust based on bound dataProvider contents having changed?

查看:306
本文介绍了如何获取Flex 3 ComboBox宽度根据绑定数据进行调整提供者内容有变化?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在Flex 3中,我在MXML组件中创建了类似于以下内容的ComboBox:

In Flex 3, I've created a ComboBox within an MXML component similar to the following:

<mx:ComboBox id="comboBox" dataProvider="{_choices}" />

<mx:Script>
<![CDATA[
  import mx.collections.ArrayCollection;
  // etc...
  public function get choices():ArrayCollection { return _choices; }

  [Bindable]
  private var _choices:ArrayCollection =
    new ArrayCollection( [ { data: "ALL", label: "All" } ] );
  // etc...
]]>
</mx:Script>

</mx:HBox>

在父MXML应用程序中,我正在修改choices属性的内容:

In the parent MXML application, I'm modifying the contents of the choices property:

myComponentId.choices.removeAll();
myComponentId.choices.addItem({data: "NY", label: "New York"});
myComponentId.choices.addItem({data: "CA", label: "California"});
// etc...

绑定因为ComboBox自动拾取在运行时添加的新内容,它不调整其宽度。 ComboBox的初始宽度足够宽,只显示在组件中声明的初始项All。但是,我希望并且希望ComboBox在绑定期间自动调整大小以能够显示California,但不是。

The binding is working in that the ComboBox is automatically picking up the new contents added at runtime, however it is not adjusting its width. The initial width of the ComboBox is wide enough only to show the initial item "All" declared in the component. However, I want and would have expected the ComboBox to re-size automatically during binding to be able to show "California", but it isn't.

我如何获取ComboBox更新其宽度后,我已经添加了新的更宽的标签到其dataProvider?谢谢!

How can I get the ComboBox to update its width after I have added new wider labels to its dataProvider? Thank you!

推荐答案

您可能只需要调用 invalidateProperties() invalidateDisplayList() invalidateSize(),或三者的某些组合自己),在更改数据提供者或其内容后强制更新组件的度量值。

You probably just need to call invalidateProperties(), invalidateDisplayList(), invalidateSize(), or some combination of the three (I'm something of a flex newbie myself), to force an update to the component's measurements after changing the data provider or its contents.

myComponentId.invalidateSize();
myComponentId.invalidateDisplayList();
myComponentId.invalidateProperties();

这篇关于如何获取Flex 3 ComboBox宽度根据绑定数据进行调整提供者内容有变化?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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