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>