Refer to this article from Sambhav:
http://flex.gunua.com/?p=119

--
Chetan Sachdev
http://www.riageeks.com

On Mar 14, 10:32 am, Vasu <[email protected]> wrote:
>         I have a DataGrid with five columns first one for checkboxes(In
> header,item),second one for Id,third one for Name,fourth one for phone
> number and final column is email address.
>
>  In first column of my DataGrid,i have two Renderers one is
> HeaderRenderer and other one is ItemRenderer for the same column with
> checkboxes.
> I'm writing script there only for header checkbox(Id is chkAll) and
> item renderer checkbox(Id is chk).If i select the header checkbox,all
> the item renderer checkboxes are also selected and if i deselect the
> header checkbox then deselect the all itemrenderer checkboxes.
>
> After selecting the checkBox(it may be one (or) All) i need to the
> data from the datagrid by using the button(Delete).
>
> How to do that?
>
> Here am sending the code also,
> <?xml version="1.0" encoding="utf-8"?>
> <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml";
> layout="absolute">
>
>         <mx:Script>
>                 <![CDATA[
>                         import mx.collections.ArrayCollection;
>
>                         [Bindable]
>             public var arr:ArrayCollection = new ArrayCollection();
>                 ]]>
>         </mx:Script>
>         <mx:XMLList id="employees">
>         <employee>
>                 <id>111</id>
>             <name>Christina Coenraets</name>
>             <phone>555-219-2270</phone>
>             <email>http://www.yahoo.com</email>
>             <active>true</active>
>         </employee>
>         <employee>
>                 <id>222</id>
>             <name>Joanne Wall</name>
>             <phone>555-219-2012</phone>
>             <email>http://www.gmail.com</email>
>             <active>true</active>
>         </employee>
>         <employee>
>                 <id>333</id>
>             <name>Maurice Smith</name>
>             <phone>555-219-2012</phone>
>             <email>http://www.rediffmail.com</email>
>             <active>false</active>
>         </employee>
>         <employee>
>                 <id>444</id>
>             <name>Mary Jones</name>
>             <phone>555-219-2000</phone>
>             <email>[email protected]</email>
>             <active>true</active>
>         </employee>
>     </mx:XMLList>
>
>         <mx:VBox width="100%" height="100%">
>                 <mx:DataGrid id="dg" width="100%" height="60%" rowCount="5"
> dataProvider="{employees}">
>                         <mx:columns>
>                 <mx:DataGridColumn sortable="false">
>                         <mx:headerRenderer>
>                                 <mx:Component>
>                                         <mx:HBox>
>                                                 <mx:Script>
>                                                         <![CDATA[
>                                                                 import 
> mx.controls.Alert;
>                                                         ]]>
>                                                 </mx:Script>
>                                                 <mx:CheckBox id="chkAll" 
> click="Alert.show('hi')"/>
>                                         </mx:HBox>
>                                 </mx:Component>
>                         </mx:headerRenderer>
>                         <mx:itemRenderer>
>                                 <mx:Component>
>                                         <mx:HBox>
>                                                 <mx:Script>
>                                                         <![CDATA[
>                                                                 import 
> mx.collections.ArrayCollection;
>                                                                 import 
> mx.controls.Alert;
>                                                                 /* [Bindable]
>                                                                 private var 
> arr:ArrayCollection = new
> ArrayCollection(); */
>                                                                 private 
> function getData():void {
>
>                                                                         
> if(chk.selected)
>                                                                         {
>                                                                               
>                   outerDocument.arr.addItem
> (outerDocument.dg.selectedItem.id);
>                                                                               
>                   Alert.show("array:"+outerDocument.arr);
>                                                                         }
>                                                                         else
>                                                                         {
>                                                                               
>   for(var i:uint = 0;i<outerDocument.arr.length; i+
> +)
>                                                                               
>   {
>                                                                               
>           if((outerDocument.arr.getItemAt(i)) ==
> (outerDocument.dg.selectedItem.id))
>                                                                               
>           {
>                                                                               
>                   outerDocument.arr.removeItemAt(i);
>
>                                                                               
>           }
>                                                                               
>   }
>                                                                               
>   Alert.show("array:"+outerDocument.arr);
>                                                                         }
>                                                                 }
>                                                         ]]>
>                                                 </mx:Script>
>
>                                                 <mx:CheckBox id="chk" 
> click="getData()"/>
>                                         </mx:HBox>
>                                 </mx:Component>
>                         </mx:itemRenderer>
>                 </mx:DataGridColumn>
>                 <mx:DataGridColumn dataField="id" headerText="Id"
> visible="false"/>
>                 <mx:DataGridColumn dataField="name" headerText="Name"/
>
>                 <mx:DataGridColumn dataField="phone"
> headerText="Phone"/>
>                 <mx:DataGridColumn dataField="email"
> headerText="Email"/>
>             </mx:columns>
>         </mx:DataGrid>
>
>         <mx:Form width="100%" height="100%">
>             <mx:FormItem label="Name">
>                 <mx:Label text="{dg.selectedItem.name}"/>
>             </mx:FormItem>
>             <mx:FormItem label="Email">
>                 <mx:Label text="{dg.selectedItem.email}"/>
>             </mx:FormItem>
>             <mx:FormItem label="Phone">
>                 <mx:Label text="{dg.selectedItem.phone}"/>
>             </mx:FormItem>
>         </mx:Form>
>         </mx:VBox>
>
> </mx:Application>
>
> Thanks & Regards,
> Srinivas.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Flex 
India Community" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/flex_india?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to