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

推荐订阅源

P
Proofpoint News Feed
V
Visual Studio Blog
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
T
Threatpost
TaoSecurity Blog
TaoSecurity Blog
Engineering at Meta
Engineering at Meta
T
Troy Hunt's Blog
Exploit-DB.com RSS Feed
Exploit-DB.com RSS Feed
H
Heimdal Security Blog
Webroot Blog
Webroot Blog
A
About on SuperTechFans
S
Securelist
Recorded Future
Recorded Future
K
KPMG report finds enterprise disconnect between AI and its ROI | CIO
阮一峰的网络日志
阮一峰的网络日志
S
SegmentFault 最新的问题
P
Palo Alto Networks Blog
F
Fortinet All Blogs
Hacker News: Ask HN
Hacker News: Ask HN
WordPress大学
WordPress大学
W
WeLiveSecurity
N
Netflix TechBlog - Medium
博客园 - 叶小钗
宝玉的分享
宝玉的分享
大猫的无限游戏
大猫的无限游戏
G
GRAHAM CLULEY
Schneier on Security
Schneier on Security
博客园 - 聂微东
www.infosecurity-magazine.com
www.infosecurity-magazine.com
小众软件
小众软件
博客园 - 【当耐特】
有赞技术团队
有赞技术团队
cs.CV updates on arXiv.org
cs.CV updates on arXiv.org
A
Arctic Wolf
C
CXSECURITY Database RSS Feed - CXSecurity.com
Google DeepMind News
Google DeepMind News
Security Latest
Security Latest
cs.AI updates on arXiv.org
cs.AI updates on arXiv.org
T
Threat Research - Cisco Blogs
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
Spread Privacy
Spread Privacy
罗磊的独立博客
The Hacker News
The Hacker News
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
IT之家
IT之家
B
Blog
GbyAI
GbyAI
Hugging Face - Blog
Hugging Face - Blog
Google Online Security Blog
Google Online Security Blog
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 });