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

简介: 做后台管理系统时遇到的问题,关于tab关闭后再打开不显示,或者报错 我在新的tabpanel中加入了一个grid,当我关闭再次打开就会报错Cannot read property 'addCls' of null, 原因是我在定义grid的错误 这是错误代码:   [javascript] view plaincopy   Ext.

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

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

原因是我在定义grid的错误

这是错误代码:

 

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


应该改为这个:

 

 

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

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

目录
相关文章
|
10月前
|
容器
Echarts报错 Cant read property getWidth of null的解决方案
Echarts报错 Cant read property getWidth of null的解决方案
88 0
|
8月前
【已解决】TypeError: Cannot destructure property `createHash` of ‘undefined‘ or ‘null‘
【已解决】TypeError: Cannot destructure property `createHash` of ‘undefined‘ or ‘null‘
185 1
|
7月前
|
JavaScript API
【Vue】Cannot set reactive property on undefined,null,or primitive value:undefined
【Vue】Cannot set reactive property on undefined,null,or primitive value:undefined
98 0
|
7月前
|
缓存 关系型数据库 MySQL
【异常解决】缓存报错:Null key returned for cache operation (maybe you are using named params on classes withou
【异常解决】缓存报错:Null key returned for cache operation (maybe you are using named params on classes withou
208 0
|
4月前
|
Java
Error:(15, 13) java: No property named “id” exists in source parameter(s). Did you mean “null”?
Error:(15, 13) java: No property named “id” exists in source parameter(s). Did you mean “null”?
32 1
|
10月前
|
Java 数据库连接 mybatis
There is no getter for property named ‘null‘ in ‘class
There is no getter for property named ‘null‘ in ‘class
115 0
There is no getter for property named ‘null‘ in ‘class
|
5月前
|
JavaScript API
Property ‘proxy‘ does not exist on type ‘ComponentInternalInstance | null‘.ts
Property ‘proxy‘ does not exist on type ‘ComponentInternalInstance | null‘.ts
|
6月前
|
JavaScript
TypeError: Cannot read properties of null (reading 'level')
# 一、分析问题 1、一个下拉框组件的更新由另一个下拉框组件控制被动更新列表,子级下拉框的值是由父级下拉框的值调用接口获取,每次父级下拉框值的改变都会改变子级下拉框的数据源也就是会改变子级下拉框的options,切换后之前的父级节点找不到就会报了这个错,父级节点不改变(即不切换)的话不会报错 # 二、解决方案 ## 1、vue页面的html层 ```html <div> <el-row :gutter="15"> <el-col :span="4"> <div">父级下拉框:</div> <el-select clearable v-model="parentId" @c
79 0
|
7月前
|
缓存 Cloud Native JavaScript
猫头虎的技术博客:解决npm报错 npm ERR! Cannot read properties of null (reading ‘pickAlgorithm‘)报错问题
猫头虎的技术博客:解决npm报错 npm ERR! Cannot read properties of null (reading ‘pickAlgorithm‘)报错问题
120 0
|
10月前
|
关系型数据库 MySQL
MySQL where条件is null 及is not null 的用法
MySQL where条件is null 及is not null 的用法
169 1
MySQL where条件is null 及is not null 的用法