Flex4 DataGrid中如何嵌入RadioButton
更新時間:2013年12月30日 17:57:48 作者:
本文為大家介紹下Flex4 DataGrid中嵌入RadioButton的方法,下面有個不錯的示例,感興趣的朋友可以參考下
復制代碼 代碼如下:
<s:DataGrid id="viewDg" width="100%" height="100%" fontFamily="微軟雅黑"
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="名稱" dataField="xysj02" resizable="false"/>
<s:GridColumn width="{wid*0.25}" headerText="地名" dataField="xysj02name" resizable="false"/>
<s:GridColumn width="{wid*0.35}" headerText="URL" dataField="xysj04" resizable="false"/>
<s:GridColumn width="{wid*0.13}" headerText="備注" dataField="xysj05" resizable="false"/>
</s:ArrayList>
</s:columns>
</s:DataGrid>
MXML頁面
復制代碼 代碼如下:
<?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>
<!-- 將非可視元素(例如服務、值對象)放在此處 -->
</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 will be controlled by the "prepare" function.
The radio_button should not be allowed any user interaction. Hence disabling it.-->
<s:RadioButton id="radio_button"
label=""
enabled="false"
horizontalCenter="0" verticalCenter="0" />
</s:GridItemRenderer>
相關文章
Flex中TextInput組件設置限制某些字符的輸入的方法
TextInput組件設置限制輸入例如限制某個字符的輸入、設置只能輸入某些字符等等,下面是具體的示例,喜歡的朋友可以參考下2014-01-01使用flex中的httpservice方法與java進行交互
這篇文章主要介紹了使用flex中的httpservice方法與java進行交互,需要的朋友可以參考下2014-02-02如何在Renderer中設置屬性 Renderer中設置屬性的方法實例
如何在Renderer中設置屬性 Renderer中設置屬性的方法實例,需要的朋友可以參考一下2013-06-06Flex中在Tree綁定數(shù)據(jù)后自動展開樹節(jié)點的方法
使用Tree組件在綁定數(shù)據(jù)后自動展開所有樹型節(jié)點(不需要用戶再自己點擊展開節(jié)點,會方 便許多),接下來為大家介紹下具體的實現(xiàn)2014-01-01Flex中如何動態(tài)生成DataGrid以及動態(tài)生成表頭
因某些需要,DataGrid及其表頭需要動態(tài)生成,網(wǎng)上的解決方案打多籠統(tǒng),下面有個不錯的解決方法,感興趣的朋友可以參考下2013-10-10