Flex的4 - 与DataGrid的细胞按钮 [英] Flex 4 - DataGrid with Button in cells

查看:136
本文介绍了Flex的4 - 与DataGrid的细胞按钮的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我如何添加在DataGrid细胞一个按钮控制?我期待有在DataGrid中一列的每一行中的按钮。 DataGrid控件行不需要以任何方式可选。

How can I add a button control in cells of a datagrid? I'm looking to have a button in each row of one column in the datagrid. The datagrid control rows don't need to be selectable in any way.

推荐答案

这真的很简单。只要定义一个自定义项目渲染列

It's really quite simple. Just define a custom item renderer for the column

<mx:DataGrid width="100%" height="100%" dataProvider="{this.someData}">
        <mx:columns>                
            <mx:DataGridColumn headerText="Buttons" >
                <mx:itemRenderer>
                    <fx:Component>
                        <s:ItemRenderer width="100%">
                            <s:Button label="{data.buttonName}" click="{outerDocument.someFunction()}" />
                        </s:ItemRenderer>
                    </fx:Component>
                </mx:itemRenderer>
            </mx:DataGridColumn>
       </mx:columns>
</mx:DataGrid>

使用数据指该行的dataProvider对象和添加outerDocument 来访问方法的项目渲染器之外。

use data to refer to the row's dataprovider object and outerDocument to access methods outside of the item renderer.

希望这有助于!

这篇关于Flex的4 - 与DataGrid的细胞按钮的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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