PDA

View Full Version : Extend a form.panel component?



xun
30 Apr 2012, 9:05 AM
I found a strange thing about a custom component that extending a form panel, a dummy component would be as the following

Ext.define('Dummy', {
extend: 'Ext.form.Panel',
border: false,


items: [],
defaults: {
border: 0
},

initComponent: function () {
var me = this;
me.items.push({ html: 'to', style: "width:20px;padding:5px" });


me.callParent();


}
}

Now try to create the dummy component in another panel twice, as the following


var item1 = Ext.create('Dummy', {
});


var item2 = Ext.create('Dummy', {
});
this.items = [item1, item2];

Instead of 2 form panels with their respective items, the second panel somehow grabs the items from the first form panel and add them to itself.

Why?

What is the proper way to extend from panel?

xun
30 Apr 2012, 9:34 AM
Found my mistake.

Should not be

me.items.push(...).

rather, should be simply
me.items = [];

thanks anyway