Reputation: 21
If I had:
var x = new Ext.form.formPanel({
});
I wanted to reuse in two places, e.g.:
var panel1 = new Ext.panel({ items:[x] });
var panel2 = new Ext.panel({ items:[x] });
Have try method Ext.extend
but it did not work. If I do that it only renders one time on the page.
Upvotes: 2
Views: 882
Reputation: 166
you can create your own formPanel class and then create this every time you want
MyForm = Ext.extend(Ext.form.FormPanel, {
title: 'My Personal Form',
width: 400,
height: 250,
padding: 10,
initComponent: function() {
this.items = [
{
xtype: 'textarea',
anchor: '100%',
fieldLabel: 'Label'
},
{
xtype: 'textfield',
fieldLabel: 'Label',
anchor: '100%'
}
];
MyForm.superclass.initComponent.call(this);
}
});
var panel1 = new Ext.panel(new MyForm({id:'test1'}));
var panel2 = new Ext.panel(new MyForm());
I insert in the first panel a id property, but you can insert anything else. You can also change the standard configuration of your form overwriting the configuration
Upvotes: 1
Reputation: 10857
Two Ext.form.FormPanel objects need to be created so you would have to do something similar to what's shown below:
var x = new Ext.form.FormPanel({
});
var y = new Ext.form.FormPanel({
});
var panel1 = new Ext.Panel({ items:[x] });
var panel2 = new Ext.Panel({ items:[y] });
Upvotes: 1