0
votes

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?

1
Are you sure this is all the code? What is the error line? - Shef

1 Answers

0
votes

You have two mistakes in your code:

  1. You don't call callParent method in your constructor. It's required when you are extending existing class:

    constructor: function(config) {
      this.initConfig(config);
      this.callParent([config]);
    }
    
  2. The store config should be specified in combobox' config:

    items: [Ext.create("com.yx.DflCombo",{
      store: ['item1', 'item2', 'item3']
    })]
    

Here is demo.