拔一拔 ExtJS 3.4 里你遇到的没遇到的 BUG(1)
本文从今天开始,我要做的就是不断的更新,不断的披露ExtJS 3.4的BUG并修复它。需要注意的是版本为3.4而不是4.0,因为4.0改动和变化比较大,所以不要对号入座。
嘿嘿,本人不怎么写东西,不过因为这些BUG困扰了我很久,所以很蛋疼,拔一拔以泄心头之恨。
本文指出的Bug修复方式不会修改原有代码,只需要外部引入一个文件即可。
不管你是否正在用该框架,或者曾经使用该框架,请注意您的ExtJS 的版本为3.4。
另外,我不保证每天更新,所以写不写文章取决于我工作中遇到了BUG。好了开拔。
观看本文需要有点Javascript基础,这个需要注意。
BUG 来源 Ext.data.DataStore
BUG 描述,引起经过使用JsonWriter进行数据自动存储。
触发BUG配置:
Ext.data.JsonWriter -> listfu : true
Ext.data.DataStore -> autoSave : true
Ext.data.DataStore -> writer 设置为listfu的JsonWriter
满足以上条件即可触发这个BUG
触发环境:
通过 Ext.data.Store的remove方法删除两条及以上数据时。
红色为引起BUG源码部分:
Ext.data.Store
remove : function(record){
if(Ext.isArray(record)){
Ext.each(record, function(r){
this.remove(r);
}, this);
return;
}
var index = this.data.indexOf(record);
if(index > -1){
record.join(null);
this.data.removeAt(index);
}
if(this.pruneModifiedRecords){
this.modified.remove(record);
}
if(this.snapshot){
this.snapshot.remove(record);
}
if(index > -1){
this.fireEvent('remove', this, record, index);
}
},
清单一
相关代码:
if (this.writer) {
this.on({
scope: this,
add: this.createRecords,
remove: this.destroyRecord,
update: this.updateRecord,
clear: this.onClear
});
}
清单二
destroyRecord : function(store, record, index) {
if (this.modified.indexOf(record) != -1) {
this.modified.remove(record);
}
if (!record.phantom) {
this.removed.push(record);
record.lastIndex = index;
if (this.autoSave === true) {
this.save();
}
}
},
清单三
好了,我简单说明一下这个BUG,因为 Store 自行添加了事件remove,所以在remove一个record(Ext.data.Record)时,会触发一个remove事件。
如清单一种的红色代码部分,这个事件被调用了。这个方法被传递到destroyRecord方法上,这时候注意代码中的this.autoSave片段。
因为开启了listful和autoSave,所以就会使用一个ajax调用。
但是因为我们删除的数据是多个,所以这个调用会被多次执行。
删除一条就执行一次,删除两条就执行两次,删除三条就执行三次。
以下是修复这个BUG的外部代码,请在ext-all.js或ext-all-debug.js后引入这段代码,你可以创建一个新的文件用于引用。
Ext.apply( Ext.data.Store.prototype, {
_bug0_remove : function( record ) {
var index = this.data.indexOf(record);
if(index > -1){
record.join(null);
this.data.removeAt(index);
}
if(this.pruneModifiedRecords){
this.modified.remove(record);
}
if(this.snapshot){
this.snapshot.remove(record);
}
if(index > -1) {
this.fireEvent('remove', this, record, index);
}
},
// 覆盖已有的方法。
remove : function(record) {
if(Ext.isArray(record)) {
Ext.each(record, function(r){
this._bug0_remove(r);
}, this);
} else {
this._bug0_remove(record);
}
if (this.autoSave === true) {
this.save();
}
},
// 覆盖已有的方法。让方法支持多个record。
destroyRecord : function(store, record, index) {
if (this.modified.indexOf(record) != -1) {
this.modified.remove(record);
}
if (!record.phantom) {
this.removed.push(record);
record.lastIndex = index;
// 除去该方法,修改调用逻辑
//if (this.autoSave === true) {
// this.save();
//}
}
},
})
拔一拔 ExtJS 3.4 里你遇到的没遇到的 BUG(1)的更多相关文章
- Extjs grid column里添加button等html标签,并增加点击事件
Extjs里有个actioncolumn,但actioncolumn只能添加一系列button,不能既有字又有button 如何能在column里增加html标签,并给button添加事件呢? 1. ...
- 火狐下<a>标签里嵌套的<select>不能选的bug
今天遇到了这个问题,网上一找就找到原因了:在狐火下<a>标签里嵌套的<select>不能选 可是我查找这个问题过程中依然饶了一些时间,原因是在<a>标签没有写hre ...
- 记录微信浏览器里word链接点击没反应的bug
有用户反应点击下载附件时没有反应,让用户把该下载链接复制到微信对话框中,发现点击该链接仍然无反应,但是在内置的手机浏览器中打开是正常的而且可以下载. 链接地址,有需要的可以拿去进行测试: http:/ ...
- Axiom3D:Ogre地形组件代码解析
大致流程. 这里简单介绍下,Axiom中采用的Ogre的地形组件的一些概念与如何生成地形. 先说下大致流程,然后大家再往下看.(只说如何生成地形与LOD,除高度纹理图外别的纹理暂时不管.) 1.生成T ...
- oracle12c新特点之可插拔数据库(Pluggable Database,PDB)
1. 12c PDB新特点的优势 1) 可以把多个PDB集成进一个平台. 2) 可以快速提供一个新的PDB或一个已有PDB的克隆. 3) 通过拔插技术,可以快速把存在的数据库重 ...
- ExtJs选择器
想要利用ExtJS的库函数对DOM进行各类操作,就要得到Element类型的对象,但是Ext.get()取到的虽然是Element,但是参数只能是id,如果大家对jQuery的selector方式很喜 ...
- extjs几个奇怪的错误
在用Extjs进行网页开发的时候,遇见了一下两个错误,这两个错误的位置用firebug调试显示在extjs-all.js Ext.resetElement is undefined g.el is n ...
- Extjs checkbox数值回显
昨天上午花了半天时间都在调 extjs的编辑页面里的CheckBox的回显问题,一直没搞定,毕竟我接触extjs才一个月不到,属于小白.先上个图: 这就是编辑页面的时候,需要的效果.然后我代码里是用了 ...
- Practical Malware Analysis里有关inetsim\APATEDNS
以前从未接触过linux,碰到了许多问题,按步骤: 1\安装VMWARE,安装ubuntu16.04 问题1:之前装的是VM10,装完后没有安装VMTOOLS,我点安装 VMTOOLS,它弹出“简易安 ...
随机推荐
- send js object to webapi or mvc
[HttpPost] public HttpResponseMessage AddInfo(UserInfoEntity userInfo) { return Request.CreateRespon ...
- oracle tablespace
oracle tablespace 1. 查看所有表空间大小 SQL> select tablespace_name,sum(bytes)/1024/1024 from dba_data_fil ...
- [C++空间分配]new运算符、operator new、placement new的区别于联系
先科普一下: 1. new的执行过程: (1)通过operator new申请内存 (2)使用placement new调用构造函数(内置类型忽略此步) (3)返回内存指针 2. new和malloc ...
- Silverlight并行下载与串行下载
思路清晰后仅仅只需百来行代码便可轻松编写出一套完整的资源动态下载组件- SerialDownloader和ParallelDownloader,它们共用一个完成资源表,且串行下载集成了优先机制(Dow ...
- cocos2d-x -------之笔记篇 动画的实现
cocos2d-x 动画的实现 一.实现原理 动画的实现其实就是使用一个完整的动作图片集来实现动画,达到动态的效果 动画动作类(CCAnimate)是加载一个动画类来实现动作. 动画类(CCAnima ...
- FAQ: Python中if __name__ == '__main__':作用
#hello.pydef sayHello(): str="hello" print(str); if __name__ == "__main__": prin ...
- stormzhang的推荐!
欢迎转载,但请务必在明确位置注明出处!http://stormzhang.com/android/2014/07/07/learn-android-from-rookie/ QQ交流群:入群理由请正确 ...
- CSS转载备忘
原文地址:http://www.cnblogs.com/coffeedeveloper/p/3145790.html#html 转载内容: 对CSS中的Position.Float属性的一些深入探讨 ...
- HTML 5 drag and drop 简介
Html 5 drag and drop 简介 HTML5提供了专门拖拽和拖放的API draggable属性 启用拖拽 draggable属性是否可被拖拽, 可选值: true, false, au ...
- IZ65534: 'JAVA.LANG.CLASSFORMATERROR' ERROR FOR A VALID IDENTIFIER
PAR status Closed as program error. Error description Error Message: The java class could not be loa ...