问题
i have a datagrid and for one of the columns im using an item renderer to display content. Im wondering is it possible to access the dataprovider content of the datagrid inside a script block in the itemRenderer.
Currently I can access the dataprovider in a component in the item renderer using data.variableName.
I want to be able do some error handling on this variable in the script block, any ideas?
回答1:
You can specify your own ItemRenderer component. Within the MXML of that component you can use the Script block however like.
Just specify the that component as the ItemRenderer like so:
<mx:DataGrid dataProvider="{ac}">
mx:columns>
<mx:DataGridColumn>
<mx:itemRenderer>
<mx:Component>
<local:YourRenderer />
</mx:Component>
</mx:itemRenderer>
</mx:DataGridColumn>
</mx:columns>
</mx:DataGrid>
回答2:
thanks,
actually what i was looking for was a way to access the properties stored in the data object in my itemRenderer inside a script block, turns out you can just call data.variableName here and it works fine , thanks anyway
回答3:
The inline itemrenderer will have an outerDocument property. This refers the document that hosts the datagrid and the itemrenderer. So you can access the datagrid and hence its dataprovider.
outerDocument.myDataGrid.dataProvider
来源:https://stackoverflow.com/questions/553964/flex-3-and-itemrenderers