PDA

View Full Version : create new instance of a form



sinaalizadeh
27 Feb 2015, 1:34 AM
I have a form with one fieldset. then I can add multiple fieldsets to it by cloneconfig. The problem is that if I create a new form will it contains more than one items (fieldset)
Is there any way to create a new object of the form OR remove extra items from my form ?





doAddTag:function(){
var newRec =Ext.create('MYAPP.model.Tag');
me.getTagForm().loadRecord(newRec);
// the form will contain more than one filedset here if the doAddFieldset method was called before
}



doAddFieldset:function(thisbutton){
var fielset = me.getTagFormFieldset().cloneConfig({
itemId:'s'+(formItemsCount +1),});
me.getTagForm().add(formItemsCount, fielset);
}

joel.watson
6 Mar 2015, 6:51 AM
I have a form with one fieldset. then I can add multiple fieldsets to it by cloneconfig. The problem is that if I create a new form will it contains more than one items (fieldset)
Is there any way to create a new object of the form OR remove extra items from my form ?


Without knowing the structure of your app a bit more, as well as what it is that you're trying to accomplish, take these suggestions with a grain of salt.

I'm assuming that "getTagForm()" is the getter produced by a ref in your controller. If so, you *could* add the forceCreate config to the ref to force it to produce a new instance of the component each time that the getter is called.

You could also just create a new instance via Ext.create('The.class.name.Here'), or via the xtype with Ext.widget( 'formxtypehere' ).

If you want to use the same instance of the form that is already extant, you could just remove the items first: myFormInstance.removeAll().

Hope that helps.

Thanks
Joel