flex中DataGrid里使用itemRenderer后数据无法绑定到数据源的问题
<?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绑定的问题。
/*如果数据只是文本的,下面的代码就可以完成你要的功能
* 注意 editable="true"
*如果是复杂的数据类型,需要在列中定义 itemEditor="{new ClassFactory(XXXX)}"
*<< 狗狗熊 奉上 >>
*/ <?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" editable="true" >
<mx:columns>
<mx:DataGridColumn headerText="name" dataField="name" editable="false"/>
<mx:DataGridColumn headerText="type" dataField="type" editable="false"/>
<mx:DataGridColumn headerText="email" dataField="steps" />
</mx:columns>
</mx:DataGrid>
<mx:Button x="326" y="513" label="测试数据" click="fun_AddImage(event)"/>
</mx:Application>
AC1=new ArrayCollection([{name:"开会",type:"紧急",steps:"0"},
{name:"结算",type:"一般",steps:"0"},
{name:"放假",type:"一般",steps:"0"}]);
}
改成:
var array1:Array = [{name:"开会",type:"紧急",steps:"0"},
{name:"结算",type:"一般",steps:"0"},
{name:"放假",type:"一般",steps:"0"}];
var array2:Array = new Array();
for(var i:int = 0;i<array1.length;i++){
array2.push(new ObjectProxy(array1[i]));
}
AC1 = new ArrayCollection(array2);
原因:ObjectProxy实现了IEventDispatcher接口
flex中DataGrid里使用itemRenderer后数据无法绑定到数据源的问题的更多相关文章
- Linq中使用反射实现--LINQ通用数据表绑定DataGrid控件的方法(原创)
项目需求,因为项目中存在很多表,这些表的内容需要呈现给客户浏览.转载请注明出处 相信很多写过程序的设计者很容易的用以下方式实现 在SqlConnect ,DataSet 的方式,我们很轻松的可以通过S ...
- WPF中DataGrid垂直滚动条滚动后导致每行CheckBox选择错乱
问题: WPF的DataGrid中出现选取或者多选以及单选的时候,出现滚动条的时候,如果发生了滚动,默认情况下就会出现已经选择的CheckBox错乱.这样的原因何在? 解决方案: 经过查阅资料,了解到 ...
- Silverlight 中datagrid控件-- 通过设置数据虚拟化加速显示
定义依赖属性作为datagrid的数据源 protected static readonly DependencyProperty ViewLogsProperty = DependencyPrope ...
- 关于EsayUI中datagrid重复提交后台查询数据的问题
直接上代码: <table id="XXXX" style="width:100%;height:100%;" class="easyui-da ...
- django django中的HTML控件及参数传递方法 以及 HTML form 里的数据是怎么被包成http request 的?如何在浏览器里查看到这些数据?
https://www.jb51.net/article/136738.htm django中的HTML控件及参数传递方法 下面小编就为大家分享一篇django中的HTML控件及参数传递方法,具有很好 ...
- HTML中head里的内容经浏览器解析后全到body里了
HTML中head里的内容经浏览器解析后全到body里了 修改完代码后,用chrome审查元素,head里的内容都到body中去了 http://bbs.csdn.net/topics/3802586 ...
- 解决:HTML中多文本域(textarea)回车后数据存入数据库,EL表达式取出异常。
问题描述: 当多文本域(textarea)回车后数据存入数据库. EL表达式取出异常,值换行倒置页面报错. 问题解决: 存值脚本代码,提交前转换\n为<br/>. <script t ...
- VB.NET中使用Linq TO SQL添加数据后获得自增长列ID
VB.NET中使用Linq TO SQL添加数据后获得自增长列ID: Dim tempOrdre As New Order With { .CustomerID = cmbCustomerName.S ...
- Flex中如何通过showAllDataTips属性使鼠标移动到图表时显示所有的数据Tips的例子
原文 http://blog.minidx.com/2008/11/10/1616.html 接下来的例子演示了Flex中如何通过showAllDataTips属性,使鼠标移动到图表时显示所有的数据T ...
随机推荐
- Mysql避免全表扫描sql查询优化 .
对查询进行优化,应尽量避免全表扫描,首先应考虑在 where 及 order by 涉及的列上建立索引: .尝试下面的技巧以避免优化器错选了表扫描: · 使用ANALYZE TABLE tbl_n ...
- MVC2.0前置
.NET MVC执行过程: 1.网址路由比对 2.执行Controller与Action 3.执行View并返回结果 在使用MVC中是由IgnoreRoute()辅助方法对比成功的,会导致程序直接跳离 ...
- bootstrap-datetimepicker时间控件
欢迎各种吐槽. 本人小前端,学习过程中,某日遇到做时间控件的需求,于是无休止的召唤了度娘,发现看不太懂.算是为自己做个笔记,也便于菜鸟级别的看的懂. 首先,我们看看点击选择时间的时候的展示页面吧 年 ...
- Js对象转String的函数 和 JSON转String
js对象转string的函数 function obj2str(o){ var r = []; if(typeof o =="string") return "" ...
- windows 自动关机命令
Windows 的关机是由Shutdown.exe程序来控制的,位于Windows\System32文件夹中.如果想让Windows 2000也实现同样的效果,可以把Shutdown.exe复制到系统 ...
- 【Leetcode】Reorder List JAVA
一.题目描述 Given a singly linked list L: L0→L1→…→Ln-1→Ln,reorder it to: L0→Ln→L1→Ln-1→L2→Ln-2→… You must ...
- 浅谈Android五大布局——LinearLayout、FrameLayout、AbsoulteLayout、RelativeLayout和TableLayout
Android的界面是有布局和组件协同完成的,布局好比是建筑里的框架,而组件则相当于建 筑里的砖瓦.组件按照布局的要求依次排列,就组成了用户所看见的界面.Android的五大布局分别是LinearLa ...
- Php 笔记4-----php 细节知识
从 php5开始 php.ini register_globals参数为OFF ,禁止全局变量. 以前的情况下, 全局变量是默认为On的 , 所以,浏览器的表单中控件,会自动根据name在服务 ...
- 性能测试之系统监控工具nmon
一.概述 本篇文章主要讲解nmon,以下为目录 1.nmon介绍 2.nmon下载.安装及使用 3.nmon analysis 分析及使用,各个项的含义 二.详细信息: 1.nmon介绍: nmon( ...
- 【LR】安装LR11后遇到的问题
(1)问题:录制脚本时无法弹出IE浏览器 解决方法: 正确的是C:\Program Files (x86)\Internet Explorer\iexplore.exe 错误是:C:\Program ...