Extjs4---Cannot read property 'addCls' of null - heirenheiren的专栏 - 博客频道 - CSDN.NET
body
{
font-family: 微软雅黑,"Microsoft YaHei", Georgia,Helvetica,Arial,sans-serif,宋体, PMingLiU,serif;
font-size: 10.5pt;
line-height: 1.5;
}
html, body
{
}
h1 {
font-size:1.5em;
font-weight:bold;
}
h2 {
font-size:1.4em;
font-weight:bold;
}
h3 {
font-size:1.3em;
font-weight:bold;
}
h4 {
font-size:1.2em;
font-weight:bold;
}
h5 {
font-size:1.1em;
font-weight:bold;
}
h6 {
font-size:1.0em;
font-weight:bold;
}
img {
border:0;
max-width: 100%;
height: auto !important;
}
blockquote {
margin-top:0px;
margin-bottom:0px;
}
table {
border-collapse:collapse;
border:1px solid #bbbbbb;
}
td {
border-collapse:collapse;
border:1px solid #bbbbbb;
}
Extjs4---Cannot read property 'addCls' of null - heirenheiren的专栏 - 博客频道 - CSDN.NET
用Extjs4 MVC做后台管理系统时,通过点击左边导航菜单往tabpanel添加tab,然后关闭再打开某个tab,结果tabpanel不能显示tab,系统页面处于崩溃状态,并且浏览器报错Cannot
read property 'addCls' of null。
经分析查阅网上资料得知,原因是:定义grid的时候添加序号这行代码:new Ext.grid.RowNumberer()引起的。如果没有这样代码,系统运行正常。
当用Extjs创建(create)一个window,panel时,或者就是new一个RowNumberer这样的组件,当window关闭时,它会把自己内部包含的组件也destroy掉,这样你第二次
create 这个window的时候,内部引用的那个组件已经被销毁了,就错误产生了。
但如果是通过{xtype:'xxx'}这种形式获得组件,那么每一次 create 都会重新创建内部组件,就不会产生错误。所以建议是内部 items 里保持{xtype:'xxx'}形式定义子组件,但是这个gird序号功能暂时没有{xtype:'xxx'}这种方式获取组件,只能是通过create去创建出来。
出错误代码:
- Ext.define('WEB.view.stage.slide.SlideGridView',
- {
- extend:'Ext.grid.Panel',
- alias:'widget.slideGridView',
- stripeRows:true,
- loadMask:true,
- selType: 'checkboxmodel',
- columnLines: true,
- store: 'SlideStore',
- columns:[
- Ext.create('Ext.grid.RowNumberer', {
- text: '序号',
- width : 40,
- align:'center'
- }),
- {sortable:false, width:250, align:'left',dataIndex:'bgImgUrl',text:'背景图片'},
- {sortable:false, width:250, align:'left',dataIndex:'desImgUrl',text:'描述图片'},
- {sortable:false, flex:1, align:'left',dataIndex:'slideHref',text:'滑动链接'},
- {dataIndex:'slideId',text:'滑动ID',hidden:true},
- ],
- dockedItems: [{
- xtype: 'pagingtoolbar',
- store: 'SlideStore',
- dock:"bottom",
- enableOverflow:true,
- displayInfo: true,
- emptyMsg: '没有数据',
- displayMsg: '当前显示{0}-{1}条记录 / 共{2}条记录 ',
- beforePageText: '第',
- afterPageText: '页/共{0}页'
- }]
- });
Ext.define('WEB.view.stage.slide.SlideGridView',
{
extend:'Ext.grid.Panel',
alias:'widget.slideGridView',
stripeRows:true,
loadMask:true,
selType: 'checkboxmodel',
columnLines: true,
store: 'SlideStore',
columns:[
Ext.create('Ext.grid.RowNumberer', {
text: '序号',
width : 40,
align:'center'
}),
{sortable:false, width:250, align:'left',dataIndex:'bgImgUrl',text:'背景图片'},
{sortable:false, width:250, align:'left',dataIndex:'desImgUrl',text:'描述图片'},
{sortable:false, flex:1, align:'left',dataIndex:'slideHref',text:'滑动链接'},
{dataIndex:'slideId',text:'滑动ID',hidden:true},
],
dockedItems: [{
xtype: 'pagingtoolbar',
store: 'SlideStore',
dock:"bottom",
enableOverflow:true,
displayInfo: true,
emptyMsg: '没有数据',
displayMsg: '当前显示{0}-{1}条记录 / 共{2}条记录 ',
beforePageText: '第',
afterPageText: '页/共{0}页'
}]
});
修改正确代码:
- Ext.define('WEB.view.stage.slide.SlideGridView',
- {
- extend:'Ext.grid.Panel',
- alias:'widget.slideGridView',
- initComponent:function(){
- Ext.apply(this,{
- stripeRows:true,
- loadMask:true,
- selType: 'checkboxmodel',
- columnLines: true,
- store: 'SlideStore',
- columns:[
- Ext.create('Ext.grid.RowNumberer', {
- text: '序号',
- width : 40,
- align:'center'
- }),
- {sortable:false, width:250, align:'left',dataIndex:'bgImgUrl',text:'背景图片'},
- {sortable:false, width:250, align:'left',dataIndex:'desImgUrl',text:'描述图片'},
- {sortable:false, flex:1, align:'left',dataIndex:'slideHref',text:'滑动链接'},
- {dataIndex:'slideId',text:'滑动ID',hidden:true},
- ],
- dockedItems: [{
- xtype: 'pagingtoolbar',
- store: 'SlideStore',
- dock:"bottom",
- enableOverflow:true,
- displayInfo: true,
- emptyMsg: '没有数据',
- displayMsg: '当前显示{0}-{1}条记录 / 共{2}条记录 ',
- beforePageText: '第',
- afterPageText: '页/共{0}页'
- }]
- });
- this.callParent(arguments);
- }
- });
Ext.define('WEB.view.stage.slide.SlideGridView',
{
extend:'Ext.grid.Panel',
alias:'widget.slideGridView',
initComponent:function(){
Ext.apply(this,{
stripeRows:true,
loadMask:true,
selType: 'checkboxmodel',
columnLines: true,
store: 'SlideStore',
columns:[
Ext.create('Ext.grid.RowNumberer', {
text: '序号',
width : 40,
align:'center'
}),
{sortable:false, width:250, align:'left',dataIndex:'bgImgUrl',text:'背景图片'},
{sortable:false, width:250, align:'left',dataIndex:'desImgUrl',text:'描述图片'},
{sortable:false, flex:1, align:'left',dataIndex:'slideHref',text:'滑动链接'},
{dataIndex:'slideId',text:'滑动ID',hidden:true},
],
dockedItems: [{
xtype: 'pagingtoolbar',
store: 'SlideStore',
dock:"bottom",
enableOverflow:true,
displayInfo: true,
emptyMsg: '没有数据',
displayMsg: '当前显示{0}-{1}条记录 / 共{2}条记录 ',
beforePageText: '第',
afterPageText: '页/共{0}页'
}]
});
this.callParent(arguments);
}
});
所以所有的属性的设置都要用apply方法设置进去,如果没有放到apply里面就会报:Uncaught TypeError: Cannot read property 'parentNode' of undefined
错误。
Extjs4---Cannot read property 'addCls' of null - heirenheiren的专栏 - 博客频道 - CSDN.NET的更多相关文章
- Extjs4---Cannot read property 'addCls' of null
用MVC做后台管理系统时遇到的问题,关于tab关闭后再打开不显示,或者报错 我在新的tabpanel中加入了一个grid,当我关闭再次打开就会报错Cannot read property 'addCl ...
- Extjs4---Cannot read property 'addCls' of null 或者 el is null 关于tab关闭后再打开不显示或者报错
做后台管理系统时遇到的问题,关于tab关闭后再打开不显示,或者报错 我在新的tabpanel中加入了一个grid,当我关闭再次打开就会报错Cannot read property 'addCls' o ...
- 百度ueditor 实例化 Cannot set property 'innerHTML' of null 完美解决方案
此时此刻,我正在用博客园推荐的TinyMCE编辑器写这个博客,突然想起最近在项目中使用百度ueditor编辑器中的一些经历.所以记录在此,与大家分享. 不得不说,百度ueditor是一款很好的在线编辑 ...
- org.hibernate.PropertyValueException: not-null property references a null or transient value:
org.hibernate.PropertyValueException: not-null property references a null or transient value: com.bj ...
- Uncaught TypeError: Cannot read property 'insertAdjacentHTML' of null
在开发Ext 项目中如果遇到 Uncaught TypeError: Cannot read property 'insertAdjacentHTML' of null 这个错误,检查下renderT ...
- extjs Cannot read property 'dom' of null
如果你的EXTJS报错: Cannot read property 'dom' of null,那就有可能是因为你的HTML或者JSP文件中的BODY标签里面少了个东西比如代码是: <html& ...
- Uncaught TypeError: Cannot set property 'innerHTML' of null
学习Chrome插件时,要在弹出页面中显示当前时间,结果怎样也显示不出来 看了 http://www.cnblogs.com/mfryf/p/3701801.html 这篇文章后感悟颇深 通过调试发现 ...
- hibernate级联保存问题,出错not-null property references a null or transient value
Servlet.service() for servlet default threw exception org.hibernate.PropertyValueException: not-null ...
- 错误:Cannot set property 'innerHTML' of null
360浏览器代码编辑器里提示错误:Cannot set property 'innerHTML' of null 原因是代码执行时要调用的内容不存在
随机推荐
- xib storyboard
initWithNibName加载xib或者storyboard BLEViewController *controller = [[BLEViewController alloc] initWith ...
- C#中使用正则表达式提取超链接地址的集中方法
一般在做爬虫或者CMS的时候经常需要提取 href链接或者是src地址.此时可以使用正则表达式轻松完成. Regex reg = new Regex(@"(?is)<a[^>]* ...
- Java学习笔记之I/O
package com.chinasofti.javase20160819; import java.io.BufferedReader; import java.io.BufferedWriter; ...
- web项目docker化的两种方法
标题所讲的两种方法其实就是创建docker镜像的两种方法 第一种:启动镜像后进入容器中操作,将需要的软件或者项目移动到容器中,安装或者部署,然后退出即可 第二种:编写dockerfile,将需要的镜像 ...
- ignite客户端找不到服务端的时候如何设置退出
ignite启动客户端时需要有服务端支持: Ignition.setClientMode(true); Ignition.start("ignite.xml"); 这里有个问题,当 ...
- TextureView+SurfaceTexture+OpenGL ES来播放视频(一)
引自:http://www.ithao123.cn/content-8733143.html 最近发现视频直播类应用层出不穷,比如233手游直播,蓝鲸直播,微录客等等什么的,连android界大神老罗 ...
- zzuli 1919 数列划分
题面: Description 晴天想把一个包含n个整数的序列a分成连续的若干段,且和最大的一段的值最小,但他有强迫症,分的段数不能超过m段,然后他就不会分了...他想问你这个分出来的和最大的一段的和 ...
- split和join函数的比较
关于split和join方法 处理对象字符串.split拆分字符串,join连接字符串 string.join(sep): 以string作为分隔符,将seq中的所有元素(字符串表示)合并成一个新的字 ...
- NSTimer内存方面的探究
今天研究一个框架,看到它对NSTimer的处理,感觉很有意思.于是自己在各种情况下都研究了一下,现总结如下. 我们用到NSTimer时,似乎习惯于会在dealloc方法中把它invalidate掉,但 ...
- AutoTile 自动拼接(六 大结局) 学习与实践
昨天在网上找了一些资源图片,这回就不用担心 背景资源不多的问题了,现在我一边 制作,一边发布文章. 各种各样,500多个,这里还是特别感谢 ,万恶的资本主义,不设密码就给我分享. 在制作前,大家看下这 ...