DataGridColumn中显示RadioButton
[1].[图片] 1.jpg
[2].[图片] 2.jpg
[3].[代码] [Flash/ActionScript/Flex]代码
[Bindable]
var temp:Array = new Array();
protected function application1_creationCompleteHandler(event:FlexEvent):void
{
var obj:Object = new Object();
obj.name = "张三";
obj.score = "60";
var obj2:Object = new Object();
obj2.name = "李四";
temp.push(obj);
temp.push(obj2);
qqq.dataProvider = temp;
}
<mx:VBox>
<mx:DataGrid id="qqq" editable="true" >
<mx:columns>
<mx:DataGridColumn headerText="名字" dataField="name" />
<mx:DataGridColumn id="item" headerText="分数" dataField="score" editorDataField="value" rendererIsEditor="true"
width="200">
<mx:itemRenderer>
<fx:Component>
<mx:HBox creationComplete="radioGroupHBox_creationCompleteHandler(event)" >
<fx:Script>
<![CDATA[
import mx.events.FlexEvent;
public function get value():Object {
return radioGroup.selectedValue;
}
override public function set data(value:Object):void {
super.data = value;
radioGroup.selectedValue = value.score;
}
public function resetRadioGroup(event:MouseEvent):void {
radioGroup.selection = null;
}
protected function radioGroupHBox_creationCompleteHandler(event:FlexEvent):void
{
outerDocument.resetBtn.addEventListener(MouseEvent.CLICK, resetRadioGroup);
}
]]>
</fx:Script>
<mx:RadioButtonGroup id="radioGroup" />
<mx:RadioButton label="优秀" value="90" groupName="radioGroup" />
<mx:RadioButton label="良好" value="80" groupName="radioGroup" />
<mx:RadioButton label="及格" value="60" groupName="radioGroup" />
</mx:HBox>
</fx:Component>
</mx:itemRenderer>
</mx:DataGridColumn>
</mx:columns>
</mx:DataGrid>
<mx:Button id="resetBtn" label="Reset" />
</mx:VBox>
[4].[代码] [Flash/ActionScript/Flex]代码<!--
<mx:DataGridColumn id="item" headerText="分数" dataField="score" editorDataField="value" rendererIsEditor="true">
radioGroup.selectedValue = value.score;
以上代码中以自己的field变化
-->
下载地址:http://www.huiyi8.com/java/actionscript/(转载请注明此处)