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 原因是代码执行时要调用的内容不存在
随机推荐
- 我的C笔记
最近更新: 1,父进程fork一个子进程,当向父进程发送一个SIGINT或其它信号时,子进程是否会接受到该信号? 2,父进程调用system执行一个程序时,向父进程发送一个信号时,system运行中的 ...
- IE11中的F12无效的问题
最近做的一个项目中,h5中的video标签IE11在有的机器上兼容,有的机器上不兼容,很是让人头疼.将IE卸载后重装又发现最新的IE11中F12开发者工具失效.面对F12失效的问题,具体解决办法如下: ...
- Cowrie蜜罐部署教程【转载】
0.蜜罐分类: 低交互:模拟服务和漏洞以便收集信息和恶意软件,但是攻击者无法和该系统进行交互: 中等交互:在一个特有的控制环境中模拟一个生产服务,允许攻击者的部分交互: 高交互:攻击者可以几乎自由的访 ...
- Linux常用Shell脚本珍藏【转载】
我们在运维中,尤其是linux运维,都知道脚本的重要性,脚本会让我们的 运维事半功倍,所以学会写脚本是我们每个linux运维必须学会的一门功课,这里收藏linux运维常用的脚本.如何学好脚本,最关键的 ...
- 剑指offer 旋转数组
class Solution { public: int minNumberInRotateArray(vector<int> rotateArray) { //常规的遍历方法时间是O(N ...
- Redis如何保存数组和对象
个人建议使用PHP自带的序列化函数serialize和unserialize函数 我们可以封装一个自己的Redis类 <?php class MyRedis{ private static $h ...
- C++设计模式-Singleton单例模式
template <typename T> class Singleton { public: template <typename... Args> static T* In ...
- oracle恢复一个数据表的方法
今天提交给客户方一个sql脚本去跟新历史数据,结果客户那边的部署人员犯了一个错误,直接拿系统账号去部署,结果第一段代码没有执行成功,结果第二段代码却执行成功了,并且已经提交了的,....由于事前没有备 ...
- Hibernate Session & Transaction详解
Hibernate Session & Transaction详解 HIbernate中的Session Session是JAVA应用程序和Hibernate进行交互时使用的主要接口,它也是持 ...
- Swift\本地文件管理
转载自:http://www.coloroud.com/2015/06/01/Swift-File-Manager/ 开头 看来Swift这趟浑水是非干不可,既然如此,那索性就来的彻底吧,来一次全方位 ...