views:

244

answers:

0

Good day StackOverFlow World!!!

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="SystemDe scription" />
        <mx:DataGridColumn headerText=" Task Description" width="300" dataField="TaskDesc ription"/>
        <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.SystemDescript ion)"/>
                    </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 completeTaskAlertHa ndler(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 completeTaskAlertHa ndler, 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...
    }
}

}

Appreciate your inputs. Thanks a lot.