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

用MVC做后台管理系统时遇到的问题,关于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);
	}

});


  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值