Code sample: CheckBox as itemRenderer for DataGridColumn (Adobe Flex)
Thursday, January 1st, 2009 - 16:51 - Code
Another useful code sample (originally posted on Experts-Exchange.com by yours truly) that allows CheckBox’s to be part of a DataGrid. This is accomplished is by setting the itemRenderer of a DataGridColumn to be a CheckBox and handling the selected and click properties of the CheckBox.
Note: It is important to set the DataGridColumn’s editable property to false as the itemRenderer itself is the itemEditor.

Code:
<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="vertical" horizontalAlign="center" verticalAlign="middle">
<mx:DataGrid id="dataGrid" editable="true">
<mx:dataProvider>
<mx:XMLList xmlns="">
<node isTrue="true" name="xxxxxxxx" location="yyyyyyy"/>
<node isTrue="false" name="xxxxxxxx" location="yyyyyyy"/>
<node isTrue="true" name="xxxxxxxx" location="yyyyyyy"/>
<node isTrue="false" name="xxxxxxxx" location="yyyyyyy"/>
<node isTrue="true" name="xxxxxxxx" location="yyyyyyy"/>
</mx:XMLList>
</mx:dataProvider>
<mx:columns>
<mx:DataGridColumn dataField="@isTrue" width="25" headerText=" " editable="false">
<mx:itemRenderer>
<mx:Component>
<mx:CheckBox selected="{(data.@isTrue == 'true')?true:false}" click="{data.@isTrue = (data.@isTrue != 'true') ? 'true' : 'false';}"/>
</mx:Component>
</mx:itemRenderer>
</mx:DataGridColumn>
<mx:DataGridColumn dataField="@name" headerText="Name"/>
<mx:DataGridColumn dataField="@location" headerText="Location"/>
</mx:columns>
</mx:DataGrid>
<mx:DataGrid dataProvider="{dataGrid.dataProvider}"/>
</mx:Application>

Nice solution Srirangan. I spent two night to do it myself.
Cheers, Andrej
This helped me out, especially the *note
Thanks for posting it
Hi Srirangan, I tried your sample for the datagrid with checkbox.
I’m trying to assign the selected values to another control.
everything works good until i sort the columns, then the datagrid’s dataprovider is empty.