Adobe Flex 组合框数据提供程序

发布于 2024-09-05 03:05:44 字数 398 浏览 1 评论 0原文

我有一个使用 Flex 3.2 SDK 编译的项目。

我的组件之一是组合框,它绑定到 Cairngorm 模型中的一个属性(称为产品)。如果我将新值插入 model.products,则组合框会立即显示新值。工作完美。

然后我转移到 3.5 SDK,运行相同的操作会导致问题。即使模型已经更新(我已经验证这肯定是这种情况),组合框也没有正确显示新值 - 它似乎知道有一个新项目,因为组合中有一个新行,但新行是空白且不可选择的。组合中的现有项目都在那里并且可以选择(因为它们应该是)。如果我重新初始化表单(即关闭并重新打开组合所在的 TitleWindow),则所有正确的值(包括新值)都会显示在组合中。

我在 3.2 和 3.5 之间来回交换了几次,以验证这确实是根本原因。

任何关于如何解决这个问题的想法将不胜感激。

I have a project that was compiled with the Flex 3.2 SDK.

One of my components is a combobox, which is bound to a property (called products) in the Cairngorm model. If I insert a new value into model.products, then the combobox immediately shows the new value. Works perfectly.

I then moved to the 3.5 SDK, and running the identical operation causes a problem. Even though the model has been updated (I have verified that this is definately the case), the combobox does not show the new value correctly - it seems to be aware that there is a new item because there is a new row in the combo, but the new row is blank and unselectable. The existing items in the combo are there and selectable (as they should be). If I re-initialising the form (i.e. close and re-open the TitleWindow on which the combo is located), then all the correct values (including the new one) are shown in the combo.

I have swapped back and forth a few times between 3.2 and 3.5 to verify that this is indeed the root cause.

Any idea on how to get around this would be greatly appreciated.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

总以为 2024-09-12 03:05:44

您是要更改 dataProvider 还是替换它?

我注意到,在 Flextras AutoCompleteComboBox 的 Flex 4 版本中,ComboBox dataProvider 有时与下拉列表的 dataProvider 不同步。我认为这都是我的错,因为我为将自动完成添加到组合框而进行了更改。

这个变化完全有可能是在 Flex 3.5 中添加的;直到我的 Flex 4 冒险之旅我才注意到这一点。

首先,当 dataProvider 更改时,我会尝试使 ComboBox 无效。您可以通过侦听集合的 collectionChange 事件来完成此操作。在事件处理程序中只需执行以下操作:

myCombo.invalidateProperties()
myCombo.invalidateDisplayList()

如果您要重新调整 dataPROvider,那么您可以尝试覆盖 set dataProvider 方法并添加如下行:

this.dropdown.dataProvider = value;

这是一个奇怪的问题。我相信在 Flex 3 / 3.2 中,每次 dataPROvider 更改时,下拉列表都会被关闭[销毁]并重新创建。看来他们在某个时候不再这样做了;这会导致这种异常。

Are you changing the dataProvider, or replacing it?

I have noticed that in the Flex 4 version of the Flextras AutoCompleteComboBox the ComboBox dataProvider sometimes get out of sync with the drop down's dataProvider. I figured this was all my fault due to the changes I made to add AutoComplete to the ComboBox.

It is entirely possible that this change was added in Flex 3.5; and I just didn't notice it until my Flex 4 adventures.

First, I'd try to invalidate the ComboBox when the dataProvider changes. You can do this by listening to the collectionChange event of the collection. In the event handler just do:

myCombo.invalidateProperties()
myCombo.invalidateDisplayList()

If you're repacing the dataPRovider, then you may try to override the set dataProvider method and add a line like this:

this.dropdown.dataProvider = value;

Is an odd issue. I believe in Flex 3 / 3.2 was that every time the dataPRovider changed the drop down was closed [destroyed] and re-created. It appears they stopped doing that at some point; which causes this anomaly.

如果没有 2024-09-12 03:05:44
//this will replace the list base on an update
private var newDropDown:ListBase;

//This addresses a bug in flex 3.5 SDK 
//where the list base does reflect changes to the data provider
//forums.adobe.com/thread/597632  
//bugs.adobe.com/jira/browse/SDK-25705 
//bugs.adobe.com/jira/browse/SDK-25567
override public function set dataProvider(value:Object):void
{
    super.dataProvider = value;
    newDropDown = dropdown;

    if(newDropDown)
    {
        validateSize(true);
        newDropDown.dataProvider = super.dataProvider;
    }
}
//this will replace the list base on an update
private var newDropDown:ListBase;

//This addresses a bug in flex 3.5 SDK 
//where the list base does reflect changes to the data provider
//forums.adobe.com/thread/597632  
//bugs.adobe.com/jira/browse/SDK-25705 
//bugs.adobe.com/jira/browse/SDK-25567
override public function set dataProvider(value:Object):void
{
    super.dataProvider = value;
    newDropDown = dropdown;

    if(newDropDown)
    {
        validateSize(true);
        newDropDown.dataProvider = super.dataProvider;
    }
}
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文