Reputation: 26360
I have a datagrid with a combobox in it like;
<mx:DataGrid editable="true" x="72" y="10" id="dataGrid" creationComplete="dataGrid_creationCompleteHandler(event)" dataProvider="{getAllResult.lastResult}" height="178" width="896">
<mx:columns>
<mx:DataGridColumn headerText="STATUS" dataField="tooltip"/>
<mx:DataGridColumn headerText="CUSTOM" editable="false" width="250" labelFunction="meAdnan" >
<mx:itemRenderer>
<fx:Component className="myEditor2">
<mx:VBox height="100%" >
<mx:ComboBox id="pickState" labelField="attname"
dataProvider="{parentApplication.getAllResult2.lastResult}"
>
</mx:ComboBox>
</mx:VBox>
</fx:Component>
</mx:itemRenderer>
</mx:DataGridColumn>
</mx:columns>
</mx:DataGrid>
Now when I want to access a function from the itemrendered/combobox i use parentApplication.funcName
but what about accessing the other way, how can I access a property of the combobox from outside the itemrenderer? I tried myEditor2.pickState
but it is now working
Upvotes: 0
Views: 1331
Reputation: 59461
parentApplication
will refer to the main Application
class which may not always be what you intend to access - what if your DataGrid
is in a component that extends Canvas
. Use outerDocument
to access the owning document from an itemRenderer
. So it should be outerDocument.funcName
.
Accessing itemRenderer instances directly is not a good idea as item renderers are reused when you scroll the list etc. So if you get a reference to the renderer instance of the first row and you scroll down the list a bit, that same instance (which you believe to be the first row) might now represent the 3rd or 5th (or whatever) row depending on how many rows you scrolled. The correct way is to override the public set data
method and manipulate it from there based on the data.
That said, you can use indexToItemRenderer method to get a reference to the current item renderer at a given index. Cast it to the correct type (or assign it to a variable typed as Object
) and read its pickState
property.
Upvotes: 1