datagrid 的值怎么传递给做 itemeditor 的 combox

china_dzkj 2011-02-22 04:34:30
条件:
1、datagrid可编辑
2、datagrid中有一列的itemeditor是combox
目的:
1、datagrid cell里面的值怎么传递给combox,并让combox显示出来呢?
...全文
136 5 点赞 打赏 收藏 举报
写回复
5 条回复
切换为时间正序
当前发帖距今超过3年,不再开放新的回复
发表回复
jilili403 2011-02-24

import mx.collections.ArrayCollection;
import mx.controls.ComboBox;
import mx.events.FlexEvent;

public class ComboBoxItemRender extends ComboBox
{
private var _data:Object;
public function ComboBoxItemRender()
{
super();
this.width = 100;
this.addEventListener(FlexEvent.VALUE_COMMIT,valueCommitHandler);
}

override public function get data():Object
{
return _data;
}

override public function set data(value:Object):void
{
this._data = value;
}

private function valueCommitHandler(event:FlexEvent):void{

}
}

然后在设置 itemRenderer="包名.ComboBoxItemRender"
  • 打赏
  • 举报
回复
jilili403 2011-02-24
我一般这么用:
import mx.collections.ArrayCollection;
import mx.controls.ComboBox;
import mx.events.FlexEvent;

public class ComboBoxItemRender extends ComboBox
{
private var _data:Object;
public function ComboBoxItemRender()
{
super();
this.width = 100;
this.addEventListener(FlexEvent.VALUE_COMMIT,valueCommitHandler);
}

override public function get data():Object
{
return _data;
}

override public function set data(value:Object):void
{
this._data = value;
}

private function valueCommitHandler(event:FlexEvent):void{

}
}

然后在设置 itemRenderer="包名.ComboBoxItemRender"
  • 打赏
  • 举报
回复
jwxkk 2011-02-23
其实就和平时给列附值一样

mx:DataGrid x="0" y="0" id="myDG" dataProvider="{_AppData}" width="100%" height="100%" itemClick="datagrid1_itemClickHandler(event)">
<mx:columns>
<mx:DataGridColumn headerText="河段" dataField="sHeDuan" />
<mx:DataGridColumn headerText="目标" dataField="sMuBiao" />

<mx:DataGridColumn headerText="现状" width="260">
<mx:itemRenderer>
<mx:Component>
<mx:HBox paddingTop="6" horizontalScrollPolicy="off" verticalScrollPolicy="off">
<mx:Image source="images/{data.sXIanZhuangImg}">
</mx:Image>
</mx:HBox>
</mx:Component>
</mx:itemRenderer>
</mx:DataGridColumn>

<mx:DataGridColumn headerText="达标">
<mx:itemRenderer>
<mx:Component>
<mx:HBox horizontalAlign="center" paddingTop="6" horizontalScrollPolicy="off" verticalScrollPolicy="off">
<mx:Image source="images/{data.sDaBiaoImg}">
</mx:Image>
</mx:HBox>
</mx:Component>
</mx:itemRenderer>
</mx:DataGridColumn>

<mx:DataGridColumn headerText="主达标项" width="130" dataField="sZHaoBiaoXiang"/>
<mx:DataGridColumn headerText="图表" dataField="sMuBiao" width="80">
<mx:itemRenderer>
<mx:Component>
<mx:HBox horizontalAlign="center" horizontalScrollPolicy="off" verticalScrollPolicy="off">
<mx:Button useHandCursor="true" buttonMode="true" click="button1_clickHandler(event)" upSkin="@Embed(source='../images/chart_line.png')" overSkin="@Embed(source='../images/chart_line.png')" downSkin="@Embed(source='../images/chart_line.png')">
<mx:Script>
<![CDATA[
protected function button1_clickHandler(event:MouseEvent):void
{
//trace(outerDocument.myDG.selectedItem.sId);
//弹出对话框
outerDocument.btnClick_Fun();
}
]]>
</mx:Script>
</mx:Button>
</mx:HBox>
</mx:Component>
</mx:itemRenderer>
</mx:DataGridColumn>



</mx:columns>
</mx:DataGrid>
  • 打赏
  • 举报
回复
china_dzkj 2011-02-22
可以具体说说怎么写代码吗?谢谢
  • 打赏
  • 举报
回复
jilili403 2011-02-22
在渲染的ComboBox中重写data的set方法
  • 打赏
  • 举报
回复
相关推荐
发帖
Flex
创建于2007-12-13

4328

社区成员

多媒体/设计 Flex
申请成为版主
帖子事件
创建了帖子
2011-02-22 04:34
社区公告
暂无公告