1 Reply Latest reply on Feb 16, 2011 11:26 AM by Flex harUI

    How to select all checkbox programmatically in a dynamically created dataGrid

    sksmylachal
      How to select all checkbox programmatically in a dynamically created dataGrid as shown below
      <![CDATA[
                    import mx.controls.dataGridClasses.DataGridColumn;
                      import mx.collections.ArrayCollection;
                 
                      import mx.controls.DataGrid;
                      import mx.controls.CheckBox;
                 
                      [Bindable]
                      private var dtGrid:DataGrid;
                        [Bindable]
                      private var chkBox:CheckBox;
                 
                      [Bindable]
                      private var peeps:ArrayCollection;
                 
                  
                 
                      private function init():void
                      {
                         peeps = new ArrayCollection();
                         peeps.addItem({firstName: "Handsome", lastName: "Dude", age: 24, sex: "male"});
                         peeps.addItem({firstName: "Red", lastName: "Bloke", age: 25, sex: "male"});
                         peeps.addItem({firstName: "Tall", lastName: "Guy", age: 25, sex: "male"});
                         peeps.addItem({firstName: "Cute", lastName: "Girl", age: 24, sex: "female"});
                         peeps.addItem({firstName: "Hot", lastName: "Chick", age: 24, sex: "female"});
                         peeps.addItem({firstName: "Lazy", lastName: "Man", age: 25, sex: "male"});
                        
                         var dataGridColumn:DataGridColumn = new DataGridColumn("");
                         dataGridColumn.itemRenderer = new ClassFactory( CheckBox );
                
                         dtGrid=new DataGrid();
                         dtGrid.dataProvider = peeps;
                         this.addElement(dtGrid);
                        
                         var tempColArray:Array = new Array();
                         tempColArray[0] = dataGridColumn;
                         for( var i:int = 0; dtGrid.columns.length > i; ++i )
                         {
                                 tempColArray[i + 1] = dtGrid.columns[i];   
                         }
                        
                         dtGrid.columns = tempColArray;
                         dtGrid.invalidateDisplayList();
                  }
                  ]]>
       
      Thanks and Regards,
      SREEJITH K S