Hi Sowmya, The problem with your code is
if(dg2.selectedItem) { Alert.show("Hi I am selected"); } if(!dg2.selectedItem) { Alert.show("Hi I am not selected"); } this condition is always true if you click on a DataGrid row to select a check box. *dg2.selectedItem * -> Will get you the currently selected row. So use id for checkbox and then using that id change the condition to <mx:CheckBox id = "myChBox" change="outerDocument.valueCheck(event)"/> if(myChBox.selected) { Alert.show(“Hi I am selected”); } if(!myChBox.selected) { Alert.show(“Hi I am not selected”); } hope it will solve your problem. Regards, Raghunathan Mohan On Thu, Jan 28, 2010 at 10:11 PM, Soumya Here <contacttosou...@gmail.com>wrote: > Hi, > > I have a problem while selecting a checkbox in a datagrid.....when I select > the checkbox it shows as selected....but when I deselect it....again it > shows as selected. > I want to track the checkbox selection is checked or not on a particular > data.....please help. > > Code as below, > > <mx:Application > xmlns:mx="http://www.adobe.com/2006/mxml" > xmlns:control="com.portal.control.*" > xmlns:business="com.portal.business.*" > xmlns:view="com.portal.view.*" > layout="absolute"> > > <mx:Script> > <![CDATA[ > import com.portal.vo.LoginVO; > import com.portal.event.CustomTextClick; > import com.portal.model.*; > import mx.collections.ArrayCollection; > import mx.controls.Alert; > [Bindable] > public var modelLocator:ModelLocator = ModelLocator.getInstance(); > > > > > //This is function called when checkbox value changed from selected to > deselected or vice versa > public function valueCheck(event:Event):void > { > > if(dg2.selectedItem) > { > Alert.show("Hi I am selected"); > } > if(!dg2.selectedItem) > { > Alert.show("Hi I am not selected"); > } > > } > > ]]> > </mx:Script> > > > > <mx:DataGrid id="dg2" dataProvider="{modelLocator.user}" x="548" y="64"> > /////Please assume for testing="{modelLocator.user}" as a ArrayCollection > <mx:columns> > > <mx:DataGridColumn headerText="Password" dataField="userPassword"/> > <mx:DataGridColumn headerText='UserId' dataField="userId"/> > > <mx:DataGridColumn headerText="Please Select"> > <mx:itemRenderer> > <mx:Component> > <mx:VBox> > <mx:CheckBox change="outerDocument.valueCheck(event)"/> > </mx:VBox> > </mx:Component> > </mx:itemRenderer> > </mx:DataGridColumn> > </mx:columns> > </mx:DataGrid> > > </mx:Application> > > > Thanks, > Soumya > > > > -- > You received this message because you are subscribed to the Google Groups > "Flex India Community" group. > To post to this group, send email to flex_in...@googlegroups.com. > To unsubscribe from this group, send email to > flex_india+unsubscr...@googlegroups.com<flex_india%2bunsubscr...@googlegroups.com> > . > 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 flex_in...@googlegroups.com. To unsubscribe from this group, send email to flex_india+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/flex_india?hl=en.