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

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

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

原因是我在定义grid的错误

这是错误代码:

 

[javascript] view plaincopy

 

  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 plaincopy

 

  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,这个问题整了两天,终于解决了

时间: 2024-09-10 16:54:51

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

[java] javax.el.PropertyNotFoundException: Property 'id' not found on type bean.Student

问题提出: 在使用MyEclipse开发Java Web时,调用DAO和Java Bean出现了如下错误: 严重: Servlet.service() for servlet [jsp] in context with path [/JDBCbyDao] threw exception [An exception occurred processing JSP page /student.jsp at line 3734: 35: <c:forEach items="${ studentL

SharePoint 2013 Error - TypeError: Unable to get property &amp;#39;replace&amp;#39; of undefined or null reference

错误信息 TypeError: Unable to get property 'replace' of undefined or null referenceTypeError: Unable to get property 'replace' of undefined or null reference TypeError: Unable to get property 'replace' of undefined or null referenceTypeError: Unable to g

Mybatis中传参包There is no getter for property named &amp;#39;XXX&amp;#39; in &amp;#39;class java.lang.String&amp;#39;

一.发现问题 <select id="queryStudentByNum" resultType="student" parameterType="string">   select num,name,phone from student  <where> <if test = " num!=null and num!='' ">AND num = #{num}</if><

解决sweetalert 无故报错 elem.className.replace Uncaught TypeError: Cannot read property &amp;#39;className&amp;#39; of null

今天碰到这么一个问题,在使用sweetalert的时候时有时无会报错  elem.className.replace Uncaught TypeError: Cannot read property 'className' of null  很简单,debug源码,发现elem在有时候会为空,为空的时候抛出异常,修改如下代码即可解决该问题  效果:  

ERROR 1045 (28000): Access denied for user &amp;#39;root&amp;#39;@&amp;#39;localhost&amp;#39; (using password: YES)

ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: YES) root@mysql ~]# mysql -p -u root Enter password:  ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: YES) ERROR 1045 (28000): Access denied

ajax-关于callback(eval(&amp;amp;#39;(&amp;amp;#39;+xhr.responseText+&amp;amp;#39;)&amp;amp;#39;));IE报错的问题

问题描述 关于callback(eval('('+xhr.responseText+')'));IE报错的问题 //这是index.js的文件 (function() { var li = function(id) { return document.getElementById(id); }; li.init = function() {// li下的init方法 // 创建一个ajax对象并返回 try { return new XMLHttpRequest(); } catch (e) {

javascript-jquery如何设置一个动态创建的 $(&amp;amp;#39;#&amp;amp;#39;).append(&amp;amp;#39;&amp;amp;#39;)中的ID?并利用它

问题描述 jquery如何设置一个动态创建的 $('#').append('')中的ID?并利用它 就比如像这样的: <script type="text/javascript"> var number=0; function next(){ $('#showdata').append('<input class="number_showdata" id="showdataid'+number+'" type="tex

【c3p0】报错:java.io.FileNotFoundException: Resource not found at path &amp;#39;/mchange-log.properties&amp;#39;

  配置项目启动初始,报错如下: 1 java.io.FileNotFoundException: Resource not found at path '/mchange-commons.properties'. 2 at com.mchange.v2.cfg.BasicPropertiesConfigSource.propertiesFromSource(BasicPropertiesConfigSource.java:64) 3 at com.mchange.v2.cfg.BasicMul

tomcat7 0-tomcat7.0运行报错:No rules found &amp;amp;#39;Server/Service/...

问题描述 tomcat7.0运行报错:No rules found 'Server/Service/... tomcat7.0下运行工程报错:No rules found matching 'Server/Service/Engine/Host/Resource' 我的web工程中有个配置: 在contextConfigLocation中配置加载app-context.xml 然后在app-context.xml文件中有个配置: < jee:jndi-lookup id="mDS"