I have a datagrid in my mxml file, say, samp.mxml.
<mx:DataGrid id="taskDataGrid" dataProvider="{initDG}" variableRowHeight="true"
editable="true" width="100%" paddingBottom="1" paddingTop="1" height="55" >
<mx:columns>
<mx:DataGridColumn dataField="Select"
editable="true"
rendererIsEditor="true"
itemRenderer="mx.controls.CheckBox"
editorDataField="selected" />
<mx:DataGridColumn dataField="TaskName"
width="220"
editable="true"
rendererIsEditor="true"
itemRenderer="components.taskComponent"/> //i call the component.
<mx:DataGridColumn dataField="TaskId"
itemRenderer="mx.controls.TextInput" />
</mx:columns>
</mx:DataGrid>
In one of the columns of the datagrid, I have to display a text input box and a button. So I have written that functionality as a separate component,i.e, taskComponent.mxml
<mx:TextInput id="TaskName"
editable="true"
text="{data.TaskName}"
mouseDown="addTaskRow(event);"
/>
<mx:Button id="searchTask" label="..." width="30" height="25" click="showPopUp();"/>
Now If i click the text input box in the component, I want another data row to be added. Earlier I had it as, if I click the datagrid, a row gets added. So I wrote the function in the samp.mxml itself. This is the function to add a data grid row.
private function addTaskRow(event:MouseEvent):void
{
taskDataGrid.dataProvider.addItem(
{
}
);
taskDataGrid.height += 30;
}
If i try to write the function in the taskComponent file, it shows the error, "Access of undefined property taskDataGrid". How do I use the datagrid in the taskComponent?