前往小程序,Get更优阅读体验!
立即前往
首页
学习
活动
专区
工具
TVP
发布
社区首页 >专栏 >Extjs4---Cannot read property 'addCls' of null 或者 el is null 关于tab关闭后再打开不显示或者报错

Extjs4---Cannot read property 'addCls' of null 或者 el is null 关于tab关闭后再打开不显示或者报错

作者头像
hbbliyong
发布2018-03-05 15:26:04
9070
发布2018-03-05 15:26:04
举报
文章被收录于专栏:hbbliyong

做后台管理系统时遇到的问题,关于tab关闭后再打开不显示,或者报错

我在新的tabpanel中加入了一个grid,当我关闭再次打开就会报错Cannot read property 'addCls' of null,

原因是我在定义grid的错误

这是错误代码:

代码语言:javascript
复制
Ext.define('HT.view.Grid',{  
    extend:'Ext.grid.Panel',  
 
    title : '人员列表',  
    width:400,  
    height:170,  
    frame:true,  
    store: {  
        fields: ['id','name','sex','age','birthday'],  
        proxy: {  
            type: 'ajax',  
            url : 'users',  
            reader: {  
                type: 'json',//Ext.data.reader.Json解析器 
                root: 'users' 
            }  
        },  
        autoLoad: true 
    },  
    columns: [//配置表格列 
 new Ext.grid.RowNumberer(),//表格行号组件 
        {header: "编号", width: 80, dataIndex: 'id', sortable: true},  
        {header: "姓名", width: 80, dataIndex: 'name', sortable: true},  
        {header: "年龄", width: 80, dataIndex: 'age', sortable: true},  
        {header: "性别", width: 80, dataIndex: 'sex', sortable: true},  
        {header: "生日", width: 80, dataIndex: 'birthdate', sortable: true}  
    ]  
 
});  

应该改为这个:

代码语言:javascript
复制
Ext.define('HT.view.Grid',{  
    extend:'Ext.grid.Panel',  
    title : '人员列表',  
 
    initComponent:function(){  
        Ext.apply(this,{  
            width:400,  
            height:170,  
            frame:true,  
            store: {  
                fields: ['id','name','sex','age','birthday'],  
                proxy: {  
                    type: 'ajax',  
                    url : 'users',  
                    reader: {  
                        type: 'json',//Ext.data.reader.Json解析器 
                        root: 'users' 
                    }  
                },  
                autoLoad: true 
            },  
            columns: [//配置表格列 
 new Ext.grid.RowNumberer(),//表格行号组件 
                {header: "编号", width: 80, dataIndex: 'id', sortable: true},  
                {header: "姓名", width: 80, dataIndex: 'name', sortable: true},  
                {header: "年龄", width: 80, dataIndex: 'age', sortable: true},  
                {header: "性别", width: 80, dataIndex: 'sex', sortable: true},  
                {header: "生日", width: 80, dataIndex: 'birthdate', sortable: true}  
            ]  
        }),  
 this.callParent(arguments);  
    }  
 
});  

看样子属性的设置都要用apply方法设置进去,nnd,这个问题整了两天,终于解决了

本文参与 腾讯云自媒体同步曝光计划,分享自作者个人站点/博客。
原始发表:2013-06-20 ,如有侵权请联系 cloudcommunity@tencent.com 删除

本文分享自 作者个人站点/博客 前往查看

如有侵权,请联系 cloudcommunity@tencent.com 删除。

本文参与 腾讯云自媒体同步曝光计划  ,欢迎热爱写作的你一起参与!

评论
登录后参与评论
0 条评论
热度
最新
推荐阅读
领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档