Extjs4---Cannot read property 'addCls' of null
小编:管理员 570阅读 2022.09.06
做后台管理系统时遇到的问题,关于tab关闭后再打开不显示,或者报错
我在新的tabpanel中加入了一个grid,当我关闭再次打开就会报错Cannot read property 'addCls' of null,
原因是我在定义grid的错误
这是错误代码:
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} ] });复制
应该改为这个:
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,这个问题整了两天,终于解决了
相关推荐
- ExtJs七(ExtJs Mvc创建ViewPort) 前言在4.1的时候,要先创建一个扩展于Ext.app.Application的类,然后用create创建它的实例来开始应用程序的。而在4.1.1,则可直接调用application方法开始执行应用程序,简化了。调用application方法,其参数是一个配置对象,主要配置项有以下三个:name:用来…
- 3DMAX提示和技巧 本主题标识使用 Civil View 的一些重要提示和技巧。常规使用屏幕分辨率至少为 1280x1024 的 Civil View。低于此分辨率时,一些面板将占用过多屏幕空间。 将视口设置为线框显示以达到最佳性能。 要尽可能简化用户界面,请在单个视口中工作并关闭 3ds Max 命令面…