PDA

View Full Version : Panel RemoveAll is not removing Components. Not returning error either.



jakejamessteele
12 Sep 2013, 2:40 PM
Hey Sencha,

I am attempting to remove some Ext.Components from my Ext.Panel. These Components are fairly standard but are floating. I am attempting to do this on a button press like:

handler: function() {
Ext.getCmp('MyPanel').removeAll();
}

However the Components are still there. Ext.getCmp('MyPanel').items.items has an array of 7 after that as well.

It may be helpful to note I create custom div's in each of the Components and they also have a Resizer.


me.alohaDivID = Ext.id();
me.alohaDiv = document.createElement('div');
me.alohaDiv.setAttribute('id', me.alohaDivID);


me.getEl().dom.appendChild(me.alohaDiv);


Are inside of all of them. Otherwise they are just basic components.

To Add them to the MyPanel I do:



var myPanel = Ext.getCmp('MyPanel');
myPanel.add(Ext.create('MyComponent', { x: 1; y: 1, width: 100, height: 100 });


How come the remove all returns no error and in console will return [] however it still has the items, and the dom is still present?

jakejamessteele
12 Sep 2013, 2:56 PM
Just to answer this in case anyone comes into this problem!

You cant remove a Component with a div inside that was manually created. To fix this I did:



listeners: {
removed: function (me, ownerCt, eOpts) {
me.getEl().dom.removeChild(me.alohaDiv);
},
}


That will remove the custom div prior to the element and the element is destroyed fine :D

Gary Schlosberg
12 Sep 2013, 7:58 PM
Glad you found your solution, and thanks for sharing with the community.