`
kimmking
  • 浏览: 536833 次
  • 性别: Icon_minigender_1
  • 来自: 中华大丈夫学院
社区版块
存档分类
最新评论

Ext.grid.EditorGridPanel的一个小问题

    博客分类:
  • ext
阅读更多

当一个页面有多个结构相同的Ext.grid.EditorGridPanel时,我们可能定义一个列信息,

var columns = [{},{},{}...]; // 1、这里指定不指定editor,

然后多次使用这个数组初始化各个Grid的ColumnModel:

var cm = new new Ext.grid.ColumnModel(columns);

//2、 或是这里再指定editor,现象都一样。

 

然后就会出现某个Grid的某个列第一次编辑以后,其他Grid的此列都不能编辑了。

说明columns数组或是其中的各个对象被共享了。

翻开3.0源码一看,果然,直接在setConfig方法中this.config = config了,(ps:发现创建editor的代码在source中的和ext-all-debug.js中的代码是不一致的。)。

 

将这个几句代码稍微改改,不直接用config就可以实现共用了。

Ext.grid.ColumnModel.prototype.setConfig =function(config, initial){
        if(!initial){             delete this.totalWidth;
            for(var i = 0, len = this.config.length; i < len; i++){
                var c = this.config[i];
                if(c.editor){
                    c.editor.destroy();
                }
            }
        }
        this.config = [];
        this.lookup = {};
                for(var i = 0, len = config.length; i < len; i++){
            var col = Ext.apply({},config[i]);
            this.config.push(col);
            var c = Ext.applyIf(col, this.defaults);
            
            if(typeof c.renderer == "string"){
                c.renderer = Ext.util.Format[c.renderer];
            }
            if(typeof c.id == "undefined"){
                c.id = i;
            }
            if(c.editor && c.editor.isFormField){
                c.editor = new Ext.grid.GridEditor(c.editor);
            }
            this.lookup[c.id] = c;
        }
        if(!initial){
            this.fireEvent('configchange', this);
        }
    }

 

 

 

0
0
分享到:
评论
3 楼 kimmking 2009-12-17  
yiminghe 写道
我觉得其实 extjs 觉得一个 config 一般是一个组件用(效率考虑,没有深拷贝),没想到你这样一个config多个组件公用,这样的话应该你负责

Object.clone=function(deep){...}
new xx(config.clone(true));

这只是我的想法,你这样子改ext源码麻烦了点,呵呵



和几个人讨论过clone,extjs就是缺少一个json的深度clone方法。
自己实现也不难。
2 楼 yiminghe 2009-12-17  

Object.prototype.clone=function(deep){
//xxxx
}

今年某个公司的笔试题,:)
1 楼 yiminghe 2009-12-17  
我觉得其实 extjs 觉得一个 config 一般是一个组件用(效率考虑,没有深拷贝),没想到你这样一个config多个组件公用,这样的话应该你负责

Object.clone=function(deep){...}
new xx(config.clone(true));

这只是我的想法,你这样子改ext源码麻烦了点,呵呵

相关推荐

    可编辑表格Ext.grid.EditorGridPanel

    此文档是可编辑表格Ext.grid.EditorGridPanel的说明以及示例的源代码,放到eclipse里面即可运行,显示出效果!

    EXT核心API详解

    EXT核心API详解 1、Ext类 ………………………………… 2 2、Array类 …………………………… 4 ...编码一个对象/数组或其它值为一个json格式字符串(支持对象,数组,日期,字符串) destroy( Mixed arg1, Mixed (optiona

    Ext.grid.GridPanel右键菜单

    右键菜单的资料,代码已经详细描写。请仿照文件中所描述即可使用,不限于EXT4.0以上版本使用。

    ExtJS入门教程(超级详细)

    1、Ext类 ………………………………… 2 2、Array类 …………………………… 4 3、Number类 …………………………… 4 4、...73、Ext.grid.EditorGridPanel类 ……… 62 74、Ext.grid.PropertyGrid类 …………… 65

    给Extjs的GridPanel增加“合计”行

    NULL 博文链接:https://tonylian.iteye.com/blog/1735525

    ext 读取xml 可编辑grid

    ext 数据对象的定义 EditorGridPanel的使用 ext读取xml ext对各种数据格式的支持

    ExtJS下grid的一些属性说明

    1.界面修改(css style): Extjs中界面风格与我们产品本身的风格有很大不同,从边框、... 属性的作用(About Ext.grid. GroupingView, EditorGridPanel): Extjs的grid功能强大,如排序、隐藏列或移动列等,这些都有一些属

    Extjs EditorGridPanel中ComboBox列的显示问题

    为了解决这个问题需要在EditorGridPanel的ColumnModel中显示ComboBox的地方使用renderer属性,重新渲染,方法如下: 代码如下: //部门列表 var comboxDepartmentStore = new Ext.data.Store({ proxy: new Ext.data....

    GridPanel属性详解

    详细介绍GridPanel各项属性,ExtJS 普通表格:Ext.grid.GridPanel属性详解

    extjs实例与学习资料

    因为前段时间有两个专案要用到extjs技术,所以自己学了一段...grid,tree,显示树信息的TreePanel、用于显示表格的GridPanel及EditorGridPanel,还有代表应用程序窗口的Ext.Window,与数据库交付,希望对初学者带来帮助

    ExtJs2.0简明教程

    我这是根据别人写的做成PDF文档 第一章 开始ExtJS………………………………………………………………………………………………………4 1.1 获得ExtJS……………………………………………………………………...

Global site tag (gtag.js) - Google Analytics