No, you don't want to do that. You must have your renderer's checkbox state be set by a property value in the dataProvider item. Then when the checkbox is changed, change the value in the dataProvider item. To programmatically change the state of the checkbox, get a reference to the dataProvider item, and set the property value as desired.
You cannot directly access a control in a renderer because they are re-cycled. Tracy Spratt, Lariat Services, development services available _____ From: flexcoders@yahoogroups.com [mailto:flexcod...@yahoogroups.com] On Behalf Of Angelo Anolin Sent: Friday, February 26, 2010 11:19 AM To: flexcoders@yahoogroups.com Subject: [flexcoders] Accessing checkbox inside a Datagrid ItemRenderer Hi FlexCoders, Having some troubles trying to resolve this. I hope someone can give me guidelines on how I would be able to achieve this. I need to reference a checkbox inside the datagrid. Below please find some codes I have used. <mx:DataGrid id="dgCurrentTasks" width="100%" height="100%" dataProvider="{xmllcCurrentTasks}" horizontalScrollPolicy="on" verticalScrollPolicy="on" click="dgCurrentTasks_Click(event)"> <mx:columns> <mx:DataGridColumn headerText="Task ID" width="70" dataField="TaskID"/> <mx:DataGridColumn headerText="System" width="100" dataField="SystemDescription"/> <mx:DataGridColumn headerText="Task Description" width="300" dataField="TaskDescription"/> <mx:DataGridColumn headerText="Complete" width="30" textAlign="center"> <mx:itemRenderer> <mx:Component> <mx:VBox horizontalAlign="center" verticalAlign="middle"> <mx:CheckBox id="cbxComplete" click="outerDocument.cbxComplete_Click(event, data.TaskID, data.SystemDescription)"/> </mx:VBox> </mx:Component> </mx:itemRenderer> </mx:DataGridColumn> </mx:columns> </mx:DataGrid> And the function called by the checkbox inside the datagrid. public function cbxComplete_Click(e:Event, issueID:String, systemDescription:String) :void { if(e.currentTarget.selected) { Alert.show('Are you sure you want to set Task ID ' + taskID + ' to Complete?', 'Task Complete Confirmation', Alert.YES | Alert.NO, null, completeTaskAlertHandler, null, Alert.NO); } } And the alert handler private function completeTaskAlertHandler(evt:CloseEvent) { if (evt.detail == Alert.YES) { // Do the TASK COMPLETION Here. Alert.show('Setting Task Status to COMPLETE....', 'TEST ALERT'); } else { // Uncheck the checkbox which was checked. Alert.show('NO??', dgCurrentTasks.selectedIndices.toString()); //dgCurrentTasks.selectedIndices.cbxComplete.selected = false; --- This does not work... // I need to reference the checkbox here so that I could UN-Select it. } } Another question, would it be possible that instead of declaring the function completeTaskAlertHandler, is it possible to simply place it inline inside the cbxComplete_Click function? Like: public function cbxComplete_Click(e:Event, issueID:String, systemDescription:String) :void { if(e.currentTarget.selected) { Alert.show('Are you sure you want to set Task ID ' + taskID + ' to Complete?', 'Task Complete Confirmation', Alert.YES | Alert.NO, null, (completeTaskAlertHandler() { if (evt.detail == Alert.YES) { // Do the TASK COMPLETION Here. Alert.show('Setting Task Status to COMPLETE....', 'TEST ALERT'); } else { // Uncheck the checkbox which was checked. Alert.show('NO??', dgCurrentTasks.selectedIndices.toString()); //dgCurrentTasks.selectedIndices.cbxComplete.selected = false; --- This does not work... } }), null, Alert.NO); } } Appreciate your inputs. Thanks a lot. Angelo