惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

博客园 - 叶小钗
MyScale Blog
MyScale Blog
博客园 - 【当耐特】
I
InfoQ
腾讯CDC
aimingoo的专栏
aimingoo的专栏
L
LangChain Blog
人人都是产品经理
人人都是产品经理
D
DataBreaches.Net
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
Engineering at Meta
Engineering at Meta
A
About on SuperTechFans
Google DeepMind News
Google DeepMind News
Vercel News
Vercel News
C
Check Point Blog
B
Blog RSS Feed
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
美团技术团队
Stack Overflow Blog
Stack Overflow Blog
Y
Y Combinator Blog
D
Docker
MongoDB | Blog
MongoDB | Blog
量子位
博客园_首页

博客园 - lwjacky

SQL提高查询效益之in、not in、between、like等条件讲述 sqlserver查询数据的所有表名和行数 ExtJs4.1实现数据缓存 Sql 脚本文件太大 系统操作日志设计 一种简单的直观的高效的权限设计 ExtJs 常用方法 属性 C#农历类 通过C#使用googleAPI SQL SERVER 如何批量修改表和存储过程的架构 HTML特殊转义字符列表 - lwjacky - 博客园 extjs3.0 修正 ie 与 firefox字体显示差异的补丁 C#实现QQ接口软件--QQ的HTTP接口协议探究 二次开发WinWebMail邮件系统接口 C#实现汉字转换为拼音缩写的代码 C#实现将汉字转化为拼音的代码 extjs IE8下datefield的width问题 ExtJS中如何给Label添加click事件 自己的工具箱(Toolkit)
Extjs4---Cannot read property 'addCls' of null
lwjacky · 2014-06-10 · via 博客园 - lwjacky

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

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

原因是我在定义grid的错误

这是错误代码:

 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         {
23             header: "编号",
24             width: 80,
25             dataIndex: 'id',
26             sortable: true
27         }, {
28             header: "姓名",
29             width: 80,
30             dataIndex: 'name',
31             sortable: true
32         }, {
33             header: "年龄",
34             width: 80,
35             dataIndex: 'age',
36             sortable: true
37         }, {
38             header: "性别",
39             width: 80,
40             dataIndex: 'sex',
41             sortable: true
42         }, {
43             header: "生日",
44             width: 80,
45             dataIndex: 'birthdate',
46             sortable: true
47         }
48     ]
49 });

应该改为这个:

 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                 {
25                     header: "编号",
26                     width: 80,
27                     dataIndex: 'id',
28                     sortable: true
29                 }, {
30                     header: "姓名",
31                     width: 80,
32                     dataIndex: 'name',
33                     sortable: true
34                 }, {
35                     header: "年龄",
36                     width: 80,
37                     dataIndex: 'age',
38                     sortable: true
39                 }, {
40                     header: "性别",
41                     width: 80,
42                     dataIndex: 'sex',
43                     sortable: true
44                 }, {
45                     header: "生日",
46                     width: 80,
47                     dataIndex: 'birthdate',
48                     sortable: true
49                 }
50             ]
51         }),
52         this.callParent(arguments);
53     }
54 
55 });