我使用Ext.define时遇到问题

时间:2011-09-11 08:57:03

标签: javascript extjs4

我收到错误:

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",{})]
    });
});

谢谢,Molecule Man! 我尝试这样的另一个测试。

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类的类,我该怎么办?

1 个答案:

答案 0 :(得分:0)

您的代码中有两个错误:

  1. 您不在构造函数中调用callParent方法。在扩展现有课程时需要它:

    constructor: function(config) {
      this.initConfig(config);
      this.callParent([config]);
    }
    
  2. 应在combobox'config:

    中指定store配置
    items: [Ext.create("com.yx.DflCombo",{
      store: ['item1', 'item2', 'item3']
    })]
    
  3. 这是demo

相关问题