Flex4 DataGrid中嵌入RadioButton实现方式思路及代码实用指南
平时做技术实践时,很多问题不是概念不会,而是细节没串起来。拿“Flex4 DataGrid中嵌入RadioButton实现方法思路及代……”来说,它看着像小点,放到项目里常会牵出环境、配置、兼容性和维护成本。下面按实际采用顺序,把思路、关键写法和容易踩坑的地方讲清楚,便于大家直接对照操作。
<s:DataGrid id="viewDg" fontFamily="微软雅黑"
horizontalScrollPolicy="off" borderVisible="false"
dataProvider="{viewList}">
<s:columns>
<s:ArrayList>
<s:GridColumn resizable="false"
itemRenderer="Module_SchoolView.RadioButtonGridItemRenderer"/>
<s:GridColumn headerText="名称" dataField="xysj02" resizable="false"/>
<s:GridColumn headerText="地名" dataField="xysj02name" resizable="false"/>
<s:GridColumn headerText="URL" dataField="xysj04" resizable="false"/>
<s:GridColumn 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 拿到每月第几周小例子
- Flex 遍历Object键和值的示例
- Flex DataGrid 伪合并单元格实现思路
- Flex 自定义DataGrid实现根据条目某一属性值改变背景颜色
- flex 遍历Object对象内容的实现代码
- 全面了解flex的用途
相关资讯
-
08.31
原神甘雨如何样
-
08.31
勇者斗恶龙7兔子尾巴如何获得 勇者斗恶龙7前期兔子尾巴获取位置
-
08.31
勇者斗恶龙7盗贼的钥匙如何获得 勇者斗恶龙7盗贼的钥匙获取位置
-
08.31
勇者斗恶龙7金属史莱姆在哪刷 勇者斗恶龙7前期金属史莱姆刷取地点
-
08.31
鸣潮3.0版本新增成就如何全收集
-
08.31
卡鹰战术终极手册是什么
游戏推荐
推荐专题
热门阅读
-
-
- Perl时间处理函数用法介绍实用指南
- 08.31
-
- 《魔兽世界》12.0地下堡说明
- 08.31
-
- 《仁王3》手甲开荒心得 手甲如何玩
- 08.31
推荐下载
-
-
下载
- |
-
-
下载
- 《行尸走肉第一章》免安装中文汉化硬盘版下载
- 单机|436 MB
- 一款以动作冒险为主题的游戏
-
-
下载
- 《街头霸王X铁拳》免安装中文汉化硬盘版下载
- 单机|111MB
- 一款非常好玩的格斗游戏
-
-
下载
- |
-
-
下载
- 《暗黑破坏神3》免安装繁体中文正式版下载
- 单机|7630 MB
- 一款以角色扮演为主题的游戏
-
-
下载
- 《马克思佩恩3》免安装硬盘版下载
- 单机|27033 MB
- 一款以第三人称射击为主题的游戏