Flex 4 - DataGrid with a button in cells

How to add a button control in datagrid cells? I am looking for a button in every row of one column in the datagrid. Datagrid control strings should not be selected in any way.

+4
source share
2 answers

It is really quite simple. Just define personalized item rendering 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 access the dataprovider string object and outerDocument to access methods outside of the element renderer.

Hope this helps!

+11
source

To do this using Flex 4 controls, i.e. Spark uses a GridItemRenderer.

There are very good examples here: http://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/spark/components/gridClasses/GridItemRenderer.html#includeExamplesSummary

0
source

Source: https://habr.com/ru/post/1339829/


All Articles