apache-flex - ItemRender 数据变化

标签 apache-flex actionscript-3 itemrenderer

我有一个带有 ItemRenderer 的列表。当我单击一个按钮时,我绑定(bind)到列表的 ArrayCollection 的一个属性就会更改。

当我点击按钮时,它确实改变了属性,但列表没有改变。

我该如何解决。

这是我的代码

<fx:Script>
    <![CDATA[

        [Bindable] 
        public var controllers:ControllerCollection = new ControllerCollection();

        private function hideTheFirstItem(evt:MouseEvent):void
        {
            (controllers[0] as Controller).meetsRequirements = false;

                    //these methods don't work unfortunatly
                    controllers.itemUpdated(controllers[0]);
                    controllers.refresh();

        }


    ]]>
</fx:Script>

<mx:List id="listControllers" dataProvider="{controllers}">
    <mx:itemRenderer>
        <fx:Component>
            <solutionItems:displaySolutionItem visible="{data.meetsRequirements}" />
        </fx:Component>
    </mx:itemRenderer>
</mx:List>
<mx:Button label="test" click="hideTheFirstItem(event)" />

(ControllerCollection 扩展 ArrayCollection)

谢谢!

文森特

最佳答案

两种方式:

  1. collection.refresh()
  2. collection.itemUpdated()

当然,ControllerCollection 不是标准的 Flex Collection 类;所以我只是假设它实现了 ICollectionView 接口(interface)。


更新: 我确实注意到您的代码设置为修改 ArrayCollection 的第一个元素

private function hideTheFirstItem(evt:MouseEvent):void
{
 (controllers[0] as Controller).meetsRequirements = false;

 //these methods don't work unfortunatly
 controllers.itemUpdated(controllers[0]);
 controllers.refresh();
}

我想确保指定集合的​​第一个元素可能不是 View 中当前可见的第一个元素。我想知道这是否给您带来了问题。

关于apache-flex - ItemRender 数据变化,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5938553/

相关文章:

actionscript-3 - Flash Player 事件冒泡/捕获模式

java - 如何使用 Log4J 设置我的 BlazeDS 实现?

apache-flex - 如何让 MovieClip 的根显示对象成为具有 Flex 的 MovieClip 对象?

android - iconitemrenderer 可点击对象?

apache-flex - 使类变量可用于外部 itemRenderer 类

xml - Flex XMLListCollection 迭代连接收集的值

actionscript-3 - 尝试了解域在 AS3 中的工作方式

flash as3 动态实例变量名/连接

actionscript-3 - 仅增加一个 ItemRender 的高度

apache-flex - Flex 中 AdvancedDataGrid 上 TreeColumn 的 ItemRenderer