1 Reply Latest reply on Jul 11, 2008 10:08 AM by Gregory Lafrance

    Checking and UnCkecking

    GeorgeWS Level 1
      I have a datagrid that has a column of checkboxs created like this:

      <mx:DataGrid id="myDataGrid2" dataProvider="{myPrograms}" width="100%" height="100%" top="0" bottom="0" left="0" right="0" themeColor="#73B9B9">
      <mx:columns>
      <mx:DataGridColumn headerText="Delete" dataField="Include" width="58" sortable="false">

      <mx:itemRenderer>
      <mx:Component>
      <mx:HBox horizontalAlign="center">
      <mx:CheckBox click="data.Include=!data.Include" selected="{data.Include}" themeColor="#73B9B9"/>
      </mx:HBox>
      </mx:Component>
      </mx:itemRenderer>
      </mx:DataGridColumn>
      </mx:columns>
      </mx:DataGrid>

      I have a check box above the datagrid:
      <mx:CheckBox id="myChecks" label="Include All" click="selectAll()" />


      When I check the check box it checks all of the checkboxs in the datagrid. works perfect:

      private function selectAll():void {
      var length : int = myDataGrid.dataProvider.length;
      for( var i : int = 0; i < length; i++ )
      {
      var item : Object = myAccounts.getItemAt( i );
      item["Include"] = '1';
      }
      myAccounts.refresh();
      }

      How do I make it so that the checkboxs in the datagrid get unchecked when I uncheck the checkbox above the datagrid?

      Thanks

      George