PDA

View Full Version : Ext.define Component create & xtype ?



q9034360
13 Sep 2014, 1:25 AM
Extjs Version: 4.2.1



Ext.define('My.Window',{
extend:'Ext.window.Window',
items: [
Ext.create('Ext.form.field.Text',{value: 'create'}),
{
xtype: 'textfield',
value: 'xtype'
}
]
});


new My.Window({title:'1'}).show();
new My.Window({title:'2'}).show();


Run:
50344

scottmartin
14 Sep 2014, 9:06 AM
Should be something like there where you use create on the instance of the class:



Ext.define('My.Window', {
extend: 'Ext.window.Window',
items: [{
xtype: 'textfield',
value: 'xtype'
}, {
xtype: 'textfield',
value: 'xtype'
}]
});

Ext.define('My.Window2', {
extend: 'Ext.window.Window',

initComponent: function() { // on instance
Ext.apply(this, {
items : [
Ext.create('Ext.form.field.Text',{value: 'create'}),
Ext.create('Ext.form.field.Text',{value: 'create'})
]
});
this.callParent(arguments);
}

});


new My.Window({
title: '1'
}).show();

new My.Window({
title: '2'
}).show();

new My.Window2({
title: '1'
}).show();

new My.Window2({
title: '2'
}).show();

q9034360
14 Sep 2014, 4:57 PM
thanks !