View Full Version : Problem replacing a fieldset in a formpanel (remove then add)

11 Jun 2009, 7:39 AM
I've a problem when I try to replace a fieldset in my formpanel. I do this to replace the field contained in it.

Here is the function which do this job:

setFieldsList: function(fieldsList) {
var formFields = this.getNewFields();

if(this.findById(this.fieldset.id)) {
var oldFieldset = this.findById(this.fieldset.id);

oldFieldset.items = formFields;

this.fieldset = oldFieldset;

When I call
this.add(this.fieldset);, the following errors appears in my firebug:

cs is undefined
for(var i = 0, len = cs.length; i < len; i++){
ext-all-debug.js (ligne 16815)

this.grid is undefined
if(this.isLocked() || (index < 0...nt()) || this.isSelected(index)) return;
ext-all-debug.js (ligne 38232)
Can someone help me for this issue?

11 Jun 2009, 8:36 AM
remove automatically destroys the child component.

try remove(c, false)

11 Jun 2009, 11:57 PM
Thank you for your answer, but it still doesn't work :-/ (the same error appears)

12 Jun 2009, 1:36 AM
I found that a 'remove' event is fired when a component is removed from a container. I listen it on my formpanel to know when my fieldset is well deleted, and then I add the new fieldset. I also tried to clone the fieldset to remove before removing it, but I still have the error described sooner.

Here is my new function:

setFieldsList: function(fieldsList) {
var formFields = this.getNewFields(fieldsList);

if(this.findById(this.fieldset.id)) {

var oldFieldset = this.findById(this.fieldset.id);
this.fieldset = oldFieldset.cloneConfig();

this.on('remove', function(oldFieldset, formFields) {

this.fieldset.items = formFields;

}.createDelegate(this, new Array(oldFieldset, formFields)));

this.remove(this.findById(oldFieldset.id), false);
}Can someone help me please?