ExtJS fieldset destroy problem (continuation)…

Okay, having some problems with the removing fieldset on a form yesterday, I got some pointers from the ExtJS forum. This is known issue in ExtJS caused by some extra elements that does not removed completely within the specified container.

They have created overrides that fixes the destroy() problem. I have tried using the overrides in my code, it indeed removes those labels completely. However, as I'm using it to destroy components inside my fieldset, It still leaves the fieldset undestroyed. So I can't really use the

 
form.findById('fieldsetid').destroy();
 

So, still another issue?

I changed my code, instead of destroying the fieldset, I destroyed all object/component inside the fieldset and add it with the new components that I wanted to add.

So now my code becomes

 
//check if this fieldset has already appended to form, destroy when already appende
if(form.findById('fieldsetid')) {
 //get the fieldset
 var oldfieldset = form.findById('fieldsetid');
 
	//iterate trough each of the component in the fieldset
	oldfieldset.items.each(function(collection,item,length){
		var i = item;
		//destroy the object within the fieldset
		for(i=item; i<length; i++){oldfieldset.items.get(i).destroy();}
	});
}
 
//set form fields object
...
 
//add the object to the fieldset
oldfieldset.add(field1,field2,field3,field4);
 
/* render the form */
form.doLayout();
 

This codes looks cleaner now :).

here's the reference from the forum:
http://extjs.com/forum/showthread.php?t=27711&highlight=fieldset+destroy
http://extjs.com/forum/showthread.php?t=25479

Tags: , , , ,
ExtJS, Programming & Web Devt |

If you enjoyed this post, please consider to leave a comment or subscribe to the feed and get future articles delivered to your feed reader.

Comments

Hi Teddy,

I found the information you have provided regarding destroying inner FieldSet’s within a Form and then destroying the items/fields of the Form, to be quite interesting. It however, does not destroy all the fields as expected (on Firefox).

Do you perhaps have some more details with this regard? Does your method work successfully on your end?

In my case, everything is destroyed except for the Label fields of each form field that I had put in my Form. It seem’s it is a bit of a pain to remove all Form fields!

Hi deepak,

yes I also had the problem of the fieldset was still staying in the form despite the input box had been removed.
However that was fixed with the code above…

Leave a comment

(required)

(required)