flex 3 and itemRenderers

2019-09-20 07:35发布

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?

3条回答
再贱就再见
2楼-- · 2019-09-20 08:01

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>
查看更多
女痞
3楼-- · 2019-09-20 08:03

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

查看更多
\"骚年 ilove
4楼-- · 2019-09-20 08:05

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
查看更多
登录 后发表回答