开发者

Buttons in AdvancedDataGrid in Flex

开发者 https://www.devze.com 2022-12-08 09:54 出处:网络
Is it possible to have a Button object in a column in an Adva开发者_StackOverflow中文版ncedDataGrid object in flex 4? And how would I do this?You can do it in flex 3, so it should be possible in flex

Is it possible to have a Button object in a column in an Adva开发者_StackOverflow中文版ncedDataGrid object in flex 4? And how would I do this?


You can do it in flex 3, so it should be possible in flex 4 too. Here is how to do it in flex 3, modify it for 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>

script:

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);
}
0

精彩评论

暂无评论...
验证码 换一张
取 消