Flex4 DataGrid中嵌入RadioButton實現(xiàn)思路及代碼
更新時間:2014年07月27日 14:41:24 投稿:whsnow
本節(jié)主要介紹了Flex4 DataGrid中嵌入RadioButton實現(xiàn)思路及代碼,需要的朋友可以參考下
<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>
<!-- 將非可視元素(例如服務(wù)、值對象)放在此處 -->
</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>
相關(guān)文章
Flex動態(tài)生成可編輯的DataGrid具體實現(xiàn)代碼
DataGrid具有以下功能:表頭是動態(tài)生成的、每行都是有序號的、每行都是可以編輯、插入、刪除、修改,接下來為大家分享下Flex如何動態(tài)生成可編輯的DataGrid2013-04-04
Flex 自定義DataGrid實現(xiàn)根據(jù)條目某一屬性值改變背景顏色
本節(jié)主要介紹了Flex DataGrid根據(jù)條目某一屬性值改變背景顏色,此DataGrid為自定義拓展的,需要的朋友可以參考下2014-07-07
Flex播放器(實現(xiàn)播放、緩沖進度條和音頻曲線顯示)
這篇文章主要介紹了Flex播放器(實現(xiàn)播放、緩沖進度條和音頻曲線顯示),需要的朋友可以參考下2014-07-07
Flex3 DataGrid拖拽到ClumnChart動態(tài)顯示圖表實現(xiàn)代碼
Flex3 DataGrid拖拽到ClumnChart動態(tài)顯示圖表(支持多行同時拖拽,重復(fù)數(shù)據(jù)不重得添加,添加了圖表右鍵菜單)等等,感興趣的朋友可以了解下啊,或許對你有所幫助2013-01-01
如何在Renderer中設(shè)置屬性 Renderer中設(shè)置屬性的方法實例
如何在Renderer中設(shè)置屬性 Renderer中設(shè)置屬性的方法實例,需要的朋友可以參考一下2013-06-06
在Flex中給datagrid添加右鍵菜單項的具體實現(xiàn)
Flex中如何給datagrid添加右鍵菜單項,其實很簡單,下面有個不錯的教程,感興趣的朋友可以參考下2013-12-12

