我在使用 Ext.define 时遇到问题
我收到错误:
events is null or not a object
有谁知道问题可能是什么?
Ext.onReady(function() {
Ext.define("com.yx.DflCombo", {
extend: "Ext.form.field.ComboBox",
config: {
name: "dfl",
fieldLabel: "category"
},
constructor: function(config) {
this.initConfig(config);
return this;
}
});
Ext.create('Ext.form.Panel', {
renderTo: Ext.getBody(),
title: 'Simple Form',
bodyPadding: 5,
width: 350,
items: [Ext.create("com.yx.DflCombo",{})]
});
});
谢谢,分子人! 我尝试另一个这样的测试。
Ext.define("com.yx.MyPanel", {
extend: "Ext.panel.Panel",
config: {
title: "Clannad"
},
constructor: function(config) {
this.initConfig(config);
this.callParent([config]);
}
});
Ext.create("Ext.panel.Panel", {
renderTo: Ext.getBody(),
width: 400,
height: 400,
title: "Key",
items: [Ext.create("com.yx.MyPanel", {})]
});
我收到错误:dockedItems 为 null 或不是对象! 我只想知道当我定义一个扩展 EXTJS 类的类时,我应该做什么?
I get the error:
events is null or not a object
Does anyone know what the problem might be?
Ext.onReady(function() {
Ext.define("com.yx.DflCombo", {
extend: "Ext.form.field.ComboBox",
config: {
name: "dfl",
fieldLabel: "category"
},
constructor: function(config) {
this.initConfig(config);
return this;
}
});
Ext.create('Ext.form.Panel', {
renderTo: Ext.getBody(),
title: 'Simple Form',
bodyPadding: 5,
width: 350,
items: [Ext.create("com.yx.DflCombo",{})]
});
});
Thanks, Molecule Man!
I try another test like this.
Ext.define("com.yx.MyPanel", {
extend: "Ext.panel.Panel",
config: {
title: "Clannad"
},
constructor: function(config) {
this.initConfig(config);
this.callParent([config]);
}
});
Ext.create("Ext.panel.Panel", {
renderTo: Ext.getBody(),
width: 400,
height: 400,
title: "Key",
items: [Ext.create("com.yx.MyPanel", {})]
});
And I get the error:dockedItems is null or not a object!
I just want to know when I define a class that extend an EXTJS class, what should I do?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您的代码中有两个错误:
您没有在构造函数中调用
callParent
方法。当您扩展现有类时,这是必需的:store
配置应在组合框的配置中指定:这里是
You have two mistakes in your code:
You don't call
callParent
method in your constructor. It's required when you are extending existing class:The
store
config should be specified in combobox' config:Here is demo.