复选框itemrenderer在datagrid中显示错误的选定值

时间:2011-12-05 07:33:11

标签: datagrid checkbox flash-builder itemrenderer

我的数据网格中有一个复选框作为itemRenderer。我从数据库表的列中设置选定的值。变量的值为“true”,但我的复选框被选中,虽然我将其selected属性设置为数据字段为真。

我的代码如下:

<mx:DataGrid id="myGD" fontSize="9" enabled="true" x="20" y="20" width="217" height="60">
    <mx:columns>
        <mx:DataGridColumn rendererIsEditor="true" editorDataField="selected" width="20" headerText="isDefault" dataField="IS_DEFAULT">
            <mx:itemRenderer>
                <fx:Component>
                    <mx:HBox horizontalAlign="left">
                        <s:CheckBox selected="{Boolean(data['IS_DEFAULT'])}" horizontalCenter="0"/>
                    </mx:HBox>
                </fx:Component>
            </mx:itemRenderer>
        </mx:DataGridColumn>
    </mx:columns>
</mx:DataGrid>

有人可以帮我理解这里出了什么问题吗? 非常感谢

1 个答案:

答案 0 :(得分:0)

项呈示器应如下所示。 实际上,我的真假值是作为String发送的。 因此,两者都被评估为真。

<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>