【问题标题】:ArrayCollection not updated via ItemRenderer (CheckBox) in FlexArrayCollection 未通过 Flex 中的 ItemRenderer (CheckBox) 更新
【发布时间】:2012-01-14 02:01:13
【问题描述】:

我在更新最初填充我的数据网格的 ArrayCollection 时遇到问题。在我的例子中,dataprovider 由 TrueFalse 作为字符串组成。这些来自我的数据库。我将数据网格的 dataProvider 设置为 ArrayCollection,并在数据网格的复选框中呈现该字段。复选框在显示时正确勾选。但是,如果我再次勾选/取消勾选复选框并尝试查看 ArrayCollection,我注意到 ArrayCollection 保持不变。我仍然得到旧值。

有人可以指导我了解我的代码中缺少什么吗?下面是我的数据网格的代码。

<mx:DataGrid id="myDataGrid" dataProvider="myArrayCollection" fontSize="9" enabled="true" x="20" y="20" width="217" height="60">
    <mx:columns>
        <mx:DataGridColumn rendererIsEditor="true" editorDataField="selected" width="20" headerText="MyField" dataField="MY_FIELD">
            <mx:itemRenderer>
                <fx:Component>
                    <mx:HBox horizontalAlign="left">
                        <s:CheckBox selected="{data.MY_FIELD == 'false' ? false : true}" horizontalCenter="0"/>
                    </mx:HBox>
                </fx:Component>
            </mx:itemRenderer>
        </mx:DataGridColumn>
    </mx:columns>
</mx:DataGrid>

【问题讨论】:

    标签: apache-flex datagrid flex4.5 itemrenderer


    【解决方案1】:

    尝试用这个替换你的复选框:

    <s:CheckBox selected="{data.MY_FIELD == 'false' ? false : true}" change="data.MY_FIELD = !data_MY_FIELD" horizontalCenter="0"/>
    

    每当用户更改 CheckBox 的状态时,这应该会翻转该值。

    【讨论】:

    • MY_FIELD 来自我的数据库查询,它填充了 Flex 中的 ArrayCollection。 ArrayCollection 设置为 [Bindable]。但它仍然不起作用?任何想法
    • 请看我修改后的答案。
    • 我还有一个问题。我的价值观是来自我的数据提供者的“真”或“假”。但是,如果我选中或取消选中一个复选框,它返回的值是 YES 或 NO,而不是返回 false 本身的 true。这很奇怪。你能告诉我这里出了什么问题吗?谢谢
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-05-01
    • 2013-03-31
    • 2014-04-09
    • 1970-01-01
    相关资源
    最近更新 更多