用户登录
用户注册

分享至

Flex4 DataGrid中如何嵌入RadioButton

  • 作者: 嗫?暁雲?
  • 来源: 51数据库
  • 2021-07-08
复制代码 代码如下:

<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>
软件
前端设计
程序设计
Java相关