Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Flex 4 - DataGrid with Button in cells

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.

like image 470
Anonymous1 Avatar asked Dec 21 '22 17:12

Anonymous1


1 Answers

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>

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

Hope this helps!

like image 71
Ian T Avatar answered Dec 28 '22 07:12

Ian T