Ideas and code for embedded RadioButton in Flex4 DataGrid
Updated: July 27, 2014 14:41:24 Submission: whsnow
This section mainly introduces the implementation ideas and code of embedded RadioButton in Flex4 DataGrid. Friends who need it can refer to it
<s:DataGrid width="100%" height="100%" fontFamily="Microsoft Yahei" horizontalScrollPolicy="off" borderVisible="false" dataProvider="{viewList}"> <s:columns> <s:ArrayList> <s:GridColumn width="{wid*0.02}" resizable="false" itemRenderer="Module_SchoolView.RadioButtonGridItemRenderer"/> <s:GridColumn width="{wid*0.25}" headerText="name" dataField="xysj02" resizable="false"/> <s:GridColumn width="{wid*0.25}" headerText="Gate name" dataField="xysj02name" resizable="false"/> <s:GridColumn width="{wid*0.35}" headerText="URL" dataField="xysj04" resizable="false"/> <s:GridColumn width="{wid*0.13}" headerText="Remark" dataField="xysj05" resizable="false"/> </s:ArrayList> </s:columns> </s:DataGrid>
MXML Page
<?xml version="1.0" encoding="utf-8"?> <s:GridItemRenderer xmlns:fx="/mxml/2009" xmlns:s="library:///flex/spark" xmlns:mx="library:///flex/mx"> <fx:Declarations> <!-- Will non-visible elements(For example, service、Value Object)Put it here --> </fx:Declarations> <fx:Script> <![CDATA[ //---------------------------------------------------------------------------------------------------------- override public function prepare(hasBeenRecycled:Boolean):void { ( hasBeenRecycled ); // We make the radio button mimic the selection status of the whole row. const selected_items: Vector.<Object> = ; if( null == selected_items ) { radio_button.selected = false; return; } if( -1 != selected_items.indexOf( data ) ) radio_button.selected = true; else radio_button.selected = false; } //---------------------------------------------------------------------------------------------------------- ]]> </fx:Script> <!--The radio button is only a visual indicator for whether the row is selected or not. The "selected" property of the radio_button will be controlled by the "prepare" function. The radio_button should not be allowed any user interaction. Hence disabling it.--> <s:RadioButton label="" enabled="false" horizontalCenter="0" verticalCenter="0" /> </s:GridItemRenderer>
Related Articles
How to dynamically generate DataGrid and dynamically generate table headers in Flex
Due to certain needs, DataGrid and its headers need to be generated dynamically. The online solutions are multi-general. There is a good solution below. Interested friends can refer to it.2013-10-10Flex AIR rebooting configuration files that need to be modified
This section mainly introduces the configuration files that need to be modified for Flex AIR restart. Friends who need it can refer to it.2014-07-07How to embed RadioButton in Flex4 DataGrid
This article introduces the method of embedding RadioButton in Flex4 DataGrid. There is a good example below. Interested friends can refer to it.2013-12-12Implementation code for vertical display of Flex Label control
The text displayed on the vertical row of the Label control is usually horizontal. Next, I will share with you a method to turn it into a vertical row. Interested children's shoes can learn it. I hope it will be helpful to you.2013-04-04Introduction to the usage example of AdvancedDataGrid in Flex
AdvancedDataGrid implements a dual-header table, which is quite practical in some cases. There is a good example below. Interested friends can refer to it.2013-10-10Analysis and solution of the error in reading content in txt file
This article mainly introduces the analysis and solution of the errors caused by Flex reading content in txt file. Friends who need it can refer to it.2014-05-05Flex Gets Small Examples of Weeks of Every Month
This section mainly introduces how to obtain Flex in which week of each month. Friends who need it can refer to it2014-07-07Example of implementing different font colors to render a text in Flex
This article will introduce in detail how to render different font colors in Flex. The specific implementation ideas and codes are as follows. Interested friends can refer to it. I hope it will be helpful to you.2013-07-07flex4.0 uses external item renderer to display List information and add image examples
Use the external item presenter to display List information and add pictures. There is a good example in this article. Friends who like it can refer to it. I hope it will be helpful to everyone.2013-09-09FLEX Get DataGrid line number and column number sample code
Getting DataGrid line number and column number is quite practical during use. Here is a detailed introduction to how FLEX is done. Interested friends can learn about it.2013-09-09