3 Replies Latest reply on Feb 10, 2010 9:53 AM by venkatsyss

    Checkbox

    venkatsyss

      hi,

       

      My question is how to select and deselect all the checkbox in the datagrid view.Herwith i attached  a screen shot  and find me the solutions.

       

       

      Thanks and Regards,

      venkat.R

        • 1. Re: Checkbox
          flexprad09 Level 2

          selected attribute of your itemrenderer File for checkbox component.

          • 2. Re: Checkbox
            archemedia Level 4

            Try this:

             

            <?xml version="1.0" encoding="utf-8"?>
            <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="vertical" creationComplete="init()">
               
                <mx:Script>
                    <![CDATA[
                        import mx.events.DragEvent;
                        import mx.collections.ArrayCollection;
                       
                        [Bindable]
                        private var dp:ArrayCollection = new ArrayCollection();
                       
                        private function init():void
                        {
                            var apa:Array = [
                                {id: 1, sel: true},
                                {id: 1, sel: true},
                                {id: 1, sel: false},
                                {id: 1, sel: true}];
                            dp.source = apa;
                        }
                       
                        private function handleSelect(value:Boolean):void
                        {
                            dp.source.forEach(
                                function callback(item:*, index:int, array:Array):void
                                {
                                    item.sel = value;
                                });
                            dp.refresh();
                        }
                       
                    ]]>
                </mx:Script>
               
                <mx:DataGrid dataProvider="{dp}" variableRowHeight="true">
                    <mx:columns>
                        <mx:DataGridColumn headerText="id" dataField="id" width="50"/>
                        <mx:DataGridColumn headerText="Selected">
                            <mx:itemRenderer>
                                <mx:Component>
                                    <mx:CheckBox selected="{data.sel}"/>
                                </mx:Component>
                            </mx:itemRenderer>
                        </mx:DataGridColumn>
                    </mx:columns>
                </mx:DataGrid>
                <mx:Button label="Select all" click="handleSelect(true)"/>
                <mx:Button label="Deselect all" click="handleSelect(false)"/>
            </mx:Application>

             

             

            Dany

            • 3. Re: Checkbox
              venkatsyss Level 1

              Yes i got it.Thanks a lot.i am very happy.

               

               

              Thanks and Regards,

              venkat.R