I have a checkbox as itemRenderer in my datagrid. I am setting the selected value from a column from my database table. The value of the variable is "true", but my checkbox is selected although I am setting its selected property to the datafield which is true.
My Code is as follows:
<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>
Can someone help me understand what is going wrong here? Many thanks
The item renderer should look like this. Actually, my true and false value was being sent as String. Hence, both were being evaluated to true.
<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>