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

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

原因是我在定义grid的错误

这是错误代码:

  1. Ext.define('HT.view.Grid',{
  2. extend:'Ext.grid.Panel',
  3. title : '人员列表',
  4. width:400,
  5. height:170,
  6. frame:true,
  7. store: {
  8. fields: ['id','name','sex','age','birthday'],
  9. proxy: {
  10. type: 'ajax',
  11. url : 'users',
  12. reader: {
  13. type: 'json',//Ext.data.reader.Json解析器
  14. root: 'users'
  15. }
  16. },
  17. autoLoad: true
  18. },
  19. columns: [//配置表格列
  20. new Ext.grid.RowNumberer(),//表格行号组件
  21. {header: "编号", width: 80, dataIndex: 'id', sortable: true},
  22. {header: "姓名", width: 80, dataIndex: 'name', sortable: true},
  23. {header: "年龄", width: 80, dataIndex: 'age', sortable: true},
  24. {header: "性别", width: 80, dataIndex: 'sex', sortable: true},
  25. {header: "生日", width: 80, dataIndex: 'birthdate', sortable: true}
  26. ]
  27. });

应该改为这个:

  1. Ext.define('HT.view.Grid',{
  2. extend:'Ext.grid.Panel',
  3. title : '人员列表',
  4. initComponent:function(){
  5. Ext.apply(this,{
  6. width:400,
  7. height:170,
  8. frame:true,
  9. store: {
  10. fields: ['id','name','sex','age','birthday'],
  11. proxy: {
  12. type: 'ajax',
  13. url : 'users',
  14. reader: {
  15. type: 'json',//Ext.data.reader.Json解析器
  16. root: 'users'
  17. }
  18. },
  19. autoLoad: true
  20. },
  21. columns: [//配置表格列
  22. new Ext.grid.RowNumberer(),//表格行号组件
  23. {header: "编号", width: 80, dataIndex: 'id', sortable: true},
  24. {header: "姓名", width: 80, dataIndex: 'name', sortable: true},
  25. {header: "年龄", width: 80, dataIndex: 'age', sortable: true},
  26. {header: "性别", width: 80, dataIndex: 'sex', sortable: true},
  27. {header: "生日", width: 80, dataIndex: 'birthdate', sortable: true}
  28. ]
  29. }),
  30. this.callParent(arguments);
  31. }
  32. });

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

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

  1. Extjs4---Cannot read property 'addCls' of null

    用MVC做后台管理系统时遇到的问题,关于tab关闭后再打开不显示,或者报错 我在新的tabpanel中加入了一个grid,当我关闭再次打开就会报错Cannot read property 'addCl ...

  2. mysql设置text字段为not null,并且没有默认值,插入报错:doesn't have a default value

    一.问题描述 在往数据库写入数据的时候,报错: '字段名' doesn't have a default value 本来这个错误是经常见到的,无非就是字段没有设置默认值造成的.奇怪的是,我这边报错的 ...

  3. Extjs4---Cannot read property 'addCls' of null - heirenheiren的专栏 - 博客频道 - CSDN.NET

    body { font-family: 微软雅黑,"Microsoft YaHei", Georgia,Helvetica,Arial,sans-serif,宋体, PMingLi ...

  4. js执行函数报错Cannot set property 'value' of null怎么解决?

    js执行函数报错Cannot set property 'value' of null 的解决方案: 原因:dom还没有完全加载 第一步:所以js建议放在body下面执行, 第二步:window.on ...

  5. hexo 报错 Cannot read property 'replace' of null

    详细错误信息: FATAL Cannot read property 'replace' of null TypeError: Cannot read property 'replace' of nu ...

  6. Hexo server报错TypeError: Cannot read property 'utcOffset' of null解决方法

    最近刚刚开始使用Hexo,新建了一篇article,运行hexo server时候总是报错Cannot read property 'offset' of null. 最后发现是因为手贱把_confi ...

  7. jquery easyui datagrid 空白条处理 自适应宽高 格式化函数formmater 初始化时会报错 cannot read property 'width'||'length' of null|undefined

    1---表格定义好之后右侧可能会有一个空白条 这个空白条是留给滚动条的,当表格中的一页的数据在页面中不能全显示时会自动出现滚动条,网上有很多事要改源码才可以修改这个,但是当项目中多处用到时,有的需要滚 ...

  8. 解决sweetalert 无故报错 elem.className.replace Uncaught TypeError: Cannot read property 'className' of null

    今天碰到这么一个问题,在使用sweetalert的时候时有时无会报错 elem.className.replace Uncaught TypeError: Cannot read property ' ...

  9. 报错”Cannot read property 'addEventListener' of null“

    1.报错:Cannot read property 'addEventListener' of null 2.解决方案: 把代码放到window.onload=function(){...}里面,因为 ...

随机推荐

  1. 准备在electron上用vue,结果卡在了sqlite3

    vue.js看书有一段时间了,也准备动手做一个electron的程序.目录似乎有两种方式搭建方式 一种是使用vue.cli构建工具,就是所谓的脚手架,分别安装vue和electron https:// ...

  2. Centos 7 搭建.net web项目

    现在的.NET Core 1.0版本是一个很小的核心,APIs和工具也并不完整,但是随着.Net Core的不断完善,补充的Apis和创新也会一起整合到.NET Framework中. 安装cento ...

  3. ScriptOJ-unique#89

    一般做法 const unique = (arr) => { const result = arr.reduce((acc, iter) => { if(acc.indexOf(iter) ...

  4. 用Django ORM实现树状结构

    前言 之前看对于用关系数据库实现树状结构的方法就知道一直做自关联的表,但是感觉自关联查询太慢了,最近看到一篇文章,感觉视野开拓了好多,文章:数据库表设计,没有最好只有最适合来自:微信. 下面就针对这里 ...

  5. Visual C++.NET设计

    首先,创建对应的工程,VS2010以及以前的版本,创建项目时都可以在CLR下找到“Windows窗体应用程序”的项目模板,但是VS2012以后的版本就没这么方便了.可以通过打开旧版本的项目来修改,也可 ...

  6. 电子技术经典资料汇总:PCB设计篇

    电子技术经典资料汇总:PCB设计篇,下面的链接是一个一个的文件下载的,也是压缩包的内容,只不过我把他们给汇总成了一个压缩包,方便大家下载,还有更多电子技术必备基础资料,通信无线类的,C语言篇的,关于电 ...

  7. 音视频编解码——RGB与YUV格式转换

    一.RGB模型与YUV模型 1.RGB模型 我们知道物理三基色分别是红(Red).绿(Green).蓝(Blue).现代的显示器技术就是通过组合不同强度的红绿蓝三原色,来达成几乎任何一种可见光的颜色. ...

  8. C#6.0语言规范(三) 基本概念

    应用程序启动 具有入口点的程序集称为应用程序.运行应用程序时,会创建一个新的应用程序域.应用程序的几个不同实例可以同时存在于同一台机器上,并且每个实例都有自己的应用程序域. 应用程序域通过充当应用程序 ...

  9. MySQL:锁

    根据加锁的范围,MySQL的锁可以分为全局锁,表级锁和行锁. 1. 全局锁 一般用于全局逻辑备份操作: 1.1 FTWRL MySQL提供了一个加全局读锁的方法.命令是:Flush tables wi ...

  10. 微信开发之获取openid及推送模板消息

    有很多的朋友再问我怎么获取code,openid之类的问题,在这里我就给大家分享一下. 在做微信支付是需要获取openid的,推送模板消息也是需要openid包括其他一些功能分享等也都是需要的,ope ...