Hi friend,
please go through this, give me feed back..

<?xml version="1.0" encoding="utf-8"?>
<s:Application xmlns:fx="http://ns.adobe.com/mxml/2009";
      xmlns:s="library://ns.adobe.com/flex/spark"
      xmlns:mx="library://ns.adobe.com/flex/mx"  width="100%" height="100%"
>
 <fx:Script>
  <![CDATA[

   import mx.collections.ArrayCollection;
   import mx.controls.Alert;
   [Bindable]
   private var arr:Array  = new Array();
   public var resultArray:ArrayCollection = new ArrayCollection(

    [{firstName:'santosh',lastName:'Kumar',city:'HYD',empCode:'1',status:0},

     {firstName:'santosh',lastName:'Kumar',city:'HYD',empCode:'2',status:0},

     {firstName:'santosh',lastName:'Kumar',city:'HYD',empCode:'3',status:0},

     {firstName:'santosh',lastName:'Kumar',city:'HYD',empCode:'4',status:0},

     {firstName:'santosh',lastName:'Kumar',city:'HYD',empCode:'5',status:0}]);
   public function onDelete():void
   {
    for(var i=0 ;i<dgEmployeeInfo.dataProvider.length;i++)
    {
     if(dgEmployeeInfo.dataProvider[i].status==1)
      resultArray.removeItemAt(i);
    }
    dgEmployeeInfo.dataProvider=resultArray;
   }
   public function testChk_clickHandler(event):void
   {

    resultArray[dgEmployeeInfo.selectedIndex].status=1;
    dgEmployeeInfo.dataProvider=resultArray;
   }

  ]]>
 </fx:Script>
 <mx:DataGrid id="dgEmployeeInfo" dataProvider="{resultArray}" x="131"
     y="95" editable="false">
  <mx:columns>
   <mx:DataGridColumn headerText="Select" dataField="Select"
          rendererIsEditor="true" editorDataField="selected">
    <mx:itemRenderer>
     <fx:Component>
      <mx:HBox>
       <s:CheckBox id="testChk"
          click="outerDocument.testChk_clickHandler(event)">
       </s:CheckBox>
      </mx:HBox>
     </fx:Component>
    </mx:itemRenderer>
   </mx:DataGridColumn>
   <mx:DataGridColumn headerText="First Name"
          dataField="firstName"/>
   <mx:DataGridColumn headerText="Last Name"
          dataField="lastName"/>
   <mx:DataGridColumn headerText="City" dataField="city"/>
   <mx:DataGridColumn headerText="Employee Code"
          dataField="empCode"/>
   <mx:DataGridColumn headerText="Status"
          dataField="status"/>
  </mx:columns>
 </mx:DataGrid>


 <mx:Button label="Delete" click="onDelete()"/>


</s:Application>

__________________________________________________________________
On Mon, Feb 28, 2011 at 12:25 PM, nirav <[email protected]> wrote:

> Hi..
> I added a checkbox in a DataGrid using ItemRenderer. I have pasted the
> code I am using below.
> <mx:DataGrid id="dgEmployeeInfo" dataProvider="{resultArray}" x="131"
> y="95" editable="false">
>        <mx:columns>
>            <mx:DataGridColumn headerText="Select"
> rendererIsEditor="true" editorDataField="selected">
>                <mx:itemRenderer>
>                    <fx:Component>
>                        <mx:HBox>
>                            <s:CheckBox id="testChk"
> click="testChk_clickHandler(event)"
> selected="{cbSelected}">
>                            </s:CheckBox>
>                            <fx:Script>
>                                <![CDATA[
>                                    [Bindable]
>                                    public var cbSelected:Boolean;
>                                    protected function
> testChk_clickHandler(event:MouseEvent):void
>                                    {
>                                        cbSelected =
> testChk.selected;
>                                    }
>                                ]]>
>                            </fx:Script>
>                        </mx:HBox>
>                    </fx:Component>
>                </mx:itemRenderer>
>            </mx:DataGridColumn>
>            <mx:DataGridColumn headerText="First Name"
> dataField="firstName"/>
>            <mx:DataGridColumn headerText="Last Name"
> dataField="lastName"/>
>            <mx:DataGridColumn headerText="City" dataField="city"/>
>            <mx:DataGridColumn headerText="Employee Code"
> dataField="empCode"/>
>        </mx:columns>
>    </mx:DataGrid>
> i also have a button outside the DataGrid, and when this button is
> clicked, I want to delete all rows which have a checked CheckBox. Can
> someone tell me how to do this?
>
> --
> 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.
>
>

-- 
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