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 原因是代码执行时要调用的内容不存在
随机推荐
- jquery:赋值
Jquery的赋值语句 $("#txtStyle").val(value); 获取操作: var val = $('#test').val(); --
- 终于购入Mac mini,发现HDMI接口与显示器不兼容,网购了一个VGA转换插头
Mac mini买到了,最便宜的i5,$647,足够了. 发现路边捡的显示器没有HDMI接口,所以在学校图书馆问了一下IT 技术支持,给我推荐了ebay上$10块钱的转换器. 名字叫 Mini Dis ...
- cout、cerr、clog
其实大家平常常会用的主要有三个:cout.cerr.clog,首先简单介绍下三者. 这三者在C++中都是标准IO库中提供的输出工具(至于有关的重载问题在此不讨论): cout:写到标准输出的ostre ...
- javaweb 国际化
国际化又称为 i18n:internationalization 软件实现国际化,需具备哪些特征:对于程序中固定使用的文本元素,例如菜单栏.导航条等中使用的文本元素.或错误提示信息,状态信息等,需要根 ...
- C++调用C#之C# COM控件
C#做界面真的是比C++方便多了,所以尝试了一下,使用C++做核心功能(例如绘图),然后用C#来做节目(例如对话框),考虑到以后可能不能使用.net,使用DLL做一个隔离层,隔离C++和C#,方便以后 ...
- HDU1258 Sum it up
Sum it up 题意:给定一个数sum,和n个数,求sum可以由这n个数里面的那几个数的和表示. Given a specified total t and a list of n integer ...
- java 持有对象
1.泛型和类型安全的容器 ArrayList,可以自动扩充大小的数组,add插入对象,get访问对象,size查看对象数目. 1 /** 2 * 泛型和类型安全的容器 3 * 2016/5/6 4 * ...
- [转]java构造方法的访问修饰符
http://my.oschina.net/u/1464678/blog/210359 1. 类(class) 可见性修饰符: public—在所有类中可见,在其他包中可以用import导 ...
- POJ 1470 Closest Common Ancestors(LCA 最近公共祖先)
其实这是一个裸求LCA的题目,我使用的是离线的Tarjan算法,但是这个题的AC对于我来说却很坎坷……首先是RE,我立马想到数组开小了,然后扩大了数组,MLE了……接着把数组调整适当大小,又交了一发, ...
- LightOJ 1030 Discovering Gold(期望)
Description You are in a cave, a long cave! The cave can be represented by a 1 x N grid. Each cell o ...