做后台管理系统时遇到的问题,关于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. tensorflow学习之(一)预测一条直线y = 0.1x + 0.3

    #预测一条y = 0.1x + 0.3的直线 import tensorflow as tf import numpy as np #科学计算模块 ''' tf.random_normal([784, ...

  2. nigx

    1.反向代理 2.负载均衡(weight:设置权重) 3.高可用(场景:当主服务器死掉后 拥有备用服务器承接后续的访问) 安装 Keepalived实现

  3. javascript字符串方法总结

    一.单引号字符串内部可以使用双引号,双引号字符串内部也可以使用单引号 "hello 'world'" 'welcome "to" js' 二.多行和转义 如果要 ...

  4. MVC+EF(CODEFIRST)+EASYUI医药MIS系统

    https://www.cnblogs.com/chenlinzhi/p/4332628.html

  5. C++ lamba使用

    Moderm Effective C++ 条款31 第206提到了按引用捕获局部变量和函数形参时,如果lambda式的生命期依赖于局部变量和函数形参的生命期,需注意空悬引用的问题. 原书的例子不够直观 ...

  6. bash编程-sed

    sed(Stream Editor)是Linux系统下的一个文本流编辑器,它将文本文件内容逐行读取到标准输出,并将此行内容写入模式空间(pattern space),然后按照给定的地址定界和命令处理匹 ...

  7. CentOS配置多公网

      最终目标是同一台服务器可以多个IP地址共同访问,在这个前提下又有如下两种方式: 多个公网IP使用同一个网关 多个公网IP使用不同网关   这两种方式区别所在:1.多个公网IP使用同一个网关,我们只 ...

  8. code2

    #include <unistd.h> #include <sys/syscall.h> #include <linux/kernel.h> #include &l ...

  9. Markdown新手教程

    目录 什么是Markdown? 用Markdown写作有什么优缺点? 有哪些比较好的Markdown写作工具? markdown语法 标题 水平分区线 引用 中划线 斜体 粗体 斜粗体 链接 图片 无 ...

  10. Git查看远程提交状态的方法

    git使用过程中,经常遇到这样的问题,已经git push 了,但是,由于冲突或者push的分支不对,导致远程的和本地的不一致. 这就需要提交后查看一下远程的是否ok. 查了一下资料,找到了一些方法, ...