1 Reply Latest reply on Jan 13, 2010 2:33 AM by Sebastien V.

    Multi-select checkBox in advanced datagrid

    rkcy Level 1

      Hi,

       

      I have a requirtement like multi-select checkBox. when select the header checkBox , all the fields(columns) has to be selected and same as unselect.

       

      Please have any sample code, please share me.

       

      thanks,

      ravi

        • 1. Re: Multi-select checkBox in advanced datagrid
          Sebastien V. Level 3

          What you need to do is implement a custom header renderer containing a checkbox. On the click event on the checkbox, the renderer must access the Datagrid and select all / none of its dataprovider elements.

           

          You should be able to access the Datagrid from within the header renderer from its owner property.

           

          Smoething like that :

           

          public class SelectionHeaderRenderer extends VBox {
                    
                    // Used CheckBox component
                    private var checkBox  :CheckBox;
                    
                    public function SelectionHeaderRenderer() {
                         checkBox = new CheckBox();
                         addChild( checkBox );
                         checkBox.addEventListener( MouseEvent.CLICK , onClick );
                    }
                    
                    private function onClick( event:MouseEvent ):void {
                         // The owner component is the parent DataGrid
                         var dataGridOwner  :DataGrid = DataGrid( owner );
          
                                  // SELECT YOUR ELEMENTS HERE
                    }
                    
               }
          

           

          with whatever selection logic you need to implement.