【问题标题】:Buttons in AdvancedDataGrid in FlexFlex 中 AdvancedDataGrid 中的按钮
【发布时间】:2009-10-11 15:56:28
【问题描述】:

是否可以在 flex 4 中的 AdvancedDataGrid 对象的列中包含 Button 对象?我该怎么做?

【问题讨论】:

    标签: actionscript-3 flash apache-flex flex4


    【解决方案1】:

    您可以在 flex 3 中做到这一点,因此在 flex 4 中也应该可以。以下是在 flex 3 中的操作方法,为 spark 修改它。

    <mx:AdvancedDataGrid id="ad" creationComplete="create();">
        <mx:columns>
            <mx:AdvancedDataGridColumn dataField="text"/>
            <mx:AdvancedDataGridColumn>
                <mx:itemRenderer>
                    <mx:Component>
                        <mx:Button label="{data.buttonLabel}" 
                            click="{outerDocument.onClick(data)}"/>
                    </mx:Component>
                </mx:itemRenderer>
            </mx:AdvancedDataGridColumn>
        </mx:columns>
    </mx:AdvancedDataGrid>
    

    脚本:

    public function create():void
    {
        var array:Array = [{text:"Text1", buttonLabel:"Bt1"},
                        {text:"Text2", buttonLabel:"Bt2"}]
        ad.dataProvider = new ArrayCollection(array);
    }
    public function onClick(item:Object):void
    {
        trace(item.text);
    }
    

    【讨论】:

    • Flex 4 应该使用 &lt;mx:Component&gt; 而不是 &lt;fx:Component>
    猜你喜欢
    • 2011-07-08
    • 2011-04-13
    • 1970-01-01
    • 2010-12-15
    • 2011-12-25
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多