如何在 ItemRenderer 中使用超出数据网格范围的变量? [英] How to use out-of-datagrid scope variable inside an ItemRenderer?

查看:13
本文介绍了如何在 ItemRenderer 中使用超出数据网格范围的变量?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用 ItemRenderer 将一组项目绑定到数据网格.我使用 data 变量来控制可绑定数据.我还有 someComponentVariable 需要插入每一行,但它在组件范围内声明,所以数据网格似乎没有重新调整它(编译错误).

I'm binding an array of items to a data grid using ItemRenderer. I use the data variable to control the bindable data. I also have someComponentVariable that need be inserted into every row but its declared at the component scope, so the data grid doesn't seem to reconize it (compile error).

如何在 ItemRenderer 中使用这个变量 (someComponentVariable)?

How can I use this variable (someComponentVariable) inside the ItemRenderer?

<mx:DataGrid id="userBonusesGrid" width="100" height="248" showHeaders="false" wordWrap="true">
    <mx:columns>
        <mx:DataGridColumn headerText="" width="36">
            <mx:itemRenderer>
                <mx:Component>
                    <mx:VBox verticalAlign="middle" horizontalAlign="center">
                        <ns1:SidePanelBonus 
                            bonusName="{data.name}" description="{data.description}" 
                            arrow="{someComponentVariable}">
                        </ns1:SidePanelBonus>   
                    </mx:VBox>
                </mx:Component>
            </mx:itemRenderer>
        </mx:DataGridColumn>
    </mx:columns>
</mx:DataGrid>

推荐答案

如果 someComponentVariable 是包含 DataGrid 的类的公共属性,则可以使用 outerDocumentcomponent 访问它.

If someComponentVariable is a public property of the class enclosing DataGrid, you can use outerDocument to access it from a component.

<ns1:SidePanelBonus bonusName="{data.name}" description="{data.description}" 
    arrow="{outerDocument.someComponentVariable}">
</ns1:SidePanelBonus>   

请参阅 创建内联项目渲染器和编辑器 以了解有关 outerDocument

See the "using the Component tag" section in Creating inline item renderers and editors for more info about outerDocument

这篇关于如何在 ItemRenderer 中使用超出数据网格范围的变量?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆