R – How do select all checkbox within iteam renderer data grid using flex


In my project I used one select all button for select all checkbox at click event. But I used datagrid, item renderer within checkbox so no id of checkbox then how to select/unselect all checkbox ?

<mx:DataGrid id=newdatagrid>

<mx:DataGridColumn headerText="1"  rendererIsEditor="true" editorDataField="selected">
<mx:CheckBox click="{data.check1 = (data.check1 != 'true') ? 'true' : 'false'};outerDocument.toggleCheckbox(data);outerDocument.calcValues();" dataChange="this.selected=outerDocument.validateCheckbox(data)"/>


How can I implement select/unselect all button for checkbox?

Best Solution

First, bind the selected property of your checkbox in the itemrenderer to the "check1" property of your dataprovider items:

<mx:CheckBox selected="{data.check1}"/>

Then set the "check1" property of each item in the dataprovider in response to a button click.

for each (var item:Object in dataProvider) {
  item.check1 = true; // or false;