当前位置: 代码网 > it编程>网页制作>Flex > Flex4 DataGrid中嵌入RadioButton实现思路及代码

Flex4 DataGrid中嵌入RadioButton实现思路及代码

2024年05月15日 Flex 我要评论
<s:datagrid id="viewdg" width="100%" height="100%" fontfamily="微软雅黑" horizontalscrollpolicy="off"
<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>
(0)

相关文章:

版权声明:本文内容由互联网用户贡献,该文观点仅代表作者本人。本站仅提供信息存储服务,不拥有所有权,不承担相关法律责任。 如发现本站有涉嫌抄袭侵权/违法违规的内容, 请发送邮件至 2386932994@qq.com 举报,一经查实将立刻删除。

发表评论

验证码:
Copyright © 2017-2025  代码网 保留所有权利. 粤ICP备2024248653号
站长QQ:2386932994 | 联系邮箱:2386932994@qq.com