【问题标题】:Flex 4 - DataGrid with Button in cellsFlex 4 - 单元格中带有按钮的 DataGrid
【发布时间】:2011-02-15 14:25:45
【问题描述】:

如何在数据网格的单元格中添加按钮控件?我希望在数据网格中一列的每一行中都有一个按钮。不需要以任何方式选择数据网格控件行。

【问题讨论】:

    标签: apache-flex datagrid button flex4


    【解决方案1】:

    这真的很简单。只需为列定义一个自定义项渲染器

    <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>
    

    使用data 引用行的dataprovider 对象,使用outerDocument 访问项目渲染器之外的方法。

    希望这会有所帮助!

    【讨论】:

      【解决方案2】:

      使用 Flex 4 控件执行此操作 - 即。 Spark 使用 GridItemRenderer。

      这里有很好的例子: http://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/spark/components/gridClasses/GridItemRenderer.html#includeExamplesSummary

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 2011-09-17
        • 2011-07-10
        • 2023-04-11
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多