flex中DataGrid里使用itemRenderer后数据无法绑定到数据源的问题

jwxkk 2010-11-30 01:56:58
<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" creationComplete="initApp()" layout="vertical" fontSize="12" backgroundColor="white">

<mx:Script>
<![CDATA[

import mx.collections.ArrayCollection;

[Bindable]
private var AC1:ArrayCollection;

private function initApp():void{
AC1=new ArrayCollection([{name:"开会",type:"紧急",steps:"0"},
{name:"结算",type:"一般",steps:"0"},
{name:"放假",type:"一般",steps:"0"}]);


}

protected function fun_AddImage(event:MouseEvent):void
{
trace(AC1);

for(var i:int=0; i<AC1.length; i++) {
trace(AC1[i].steps);

}
}

]]>
</mx:Script>

<mx:DataGrid rowCount="4" dataProvider="{AC1}" id="dg" >
<mx:columns>
<mx:DataGridColumn headerText="name" dataField="name"/>
<mx:DataGridColumn headerText="type" dataField="type"/>
<mx:DataGridColumn headerText="email">
<mx:itemRenderer>
<mx:Component>
<mx:TextInput text="{data.steps}"/>
</mx:Component>
</mx:itemRenderer>
</mx:DataGridColumn>
</mx:columns>
</mx:DataGrid>

<mx:Button x="326" y="513" label="测试数据" click="fun_AddImage(event)"/>


</mx:Application>


调试提示:
warning: unable to bind to property 'steps' on class 'Object' (class is not an IEventDispatcher)

现在需要的效果是在DG的输入框里修改了文字后,数组ac1的steps字段也会更着修改
点测试后出现的数字是在DG中输入的数字,现在的问题应该是自定义的列无法和数据源ac1中的steps绑定的问题。
谢谢
...全文
273 5 打赏 收藏 转发到动态 举报
写回复
用AI写文章
5 条回复
切换为时间正序
请发表友善的回复…
发表回复
水中影子 2010-12-01
  • 打赏
  • 举报
回复
<mx:TextInput text="{data.steps}" change="{data.steps = this.text}">
leemiki 2010-11-30
  • 打赏
  • 举报
回复
<mx:itemRenderer>
<mx:Component>
<mx:TextInput text="{data.steps}" change="changeHandler(event)">
<mx:Script>
<![CDATA[
private function changeHandler(event:Event):void{
event.target.data.steps = event.target.text;
}
]]>
</mx:Script>
</mx:TextInput>
</mx:Component>
</mx:itemRenderer>
jilili403 2010-11-30
  • 打赏
  • 举报
回复
你没有指定dataField的
jianyiaishen 2010-11-30
  • 打赏
  • 举报
回复
<mx:Component>
<mx:TextInput text="{data.steps}" change="{data.steps = this.text}">
</mx:TextInput>
</mx:Component>

你text改变的时候没有刷新数据源
你试试替换你的代码能不能行
DAVID_DEEYE 2010-11-30
  • 打赏
  • 举报
回复
现在好像能显示“data.steps”吧,应该是data.@steps,显示为对象数据,楼主试一试。

4,328

社区成员

发帖
与我相关
我的任务
社区描述
多媒体/设计 Flex
社区管理员
  • Flex
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧