How to embed Radiobutton_flex in the Flex4 DataGrid

Source: Internet
Author: User
Copy Code code as follows:

<s:datagrid id= "VIEWDG" width= "100%" height= "100%" fontfamily= "Microsoft Ya Hei"
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= "place name" datafield= "Xysj02name" resizable= "false"/>

<s:gridcolumn width= "{wid*0.35}" headertext= "URL" datafield= "xysj04" resizable= "false"/>

<s:gridcolumn width= "{wid*0.13}" headertext= "Notes" datafield= "xysj05" resizable= "false"/>
</s:ArrayList>
</s:columns>
</s:DataGrid>

Mxml page
Copy Code code as follows:

<?xml version= "1.0" encoding= "Utf-8"?>
<s:griditemrenderer xmlns:fx= "http://ns.adobe.com/mxml/2009"
Xmlns:s= "Library://ns.adobe.com/flex/spark"
xmlns:mx= "LIBRARY://NS.ADOBE.COM/FLEX/MX" >
<fx:Declarations>
<!--place non-visual elements (such as services, value objects) here-->
</fx:Declarations>
<fx:Script>
<! [cdata[

//----------------------------------------------------------------------------------------------------------

Override public Function Prepare (Hasbeenrecycled:boolean): void
{
Super.prepare (hasbeenrecycled);

We make the radio button mimic the selection status of the whole row.
Const selected_items:vector.<object> = Grid.dataGrid.selectedItems;

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 is controlled by the "prepare" function.
The Radio_button should is allowed any user interaction. Hence disabling it.-->
<s:radiobutton id= "Radio_button"
Label= ""
Enabled= "false"

Horizontalcenter= "0" verticalcenter= "0"/>

</s:GridItemRenderer>

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.