PDA

View Full Version : Move Panels



NeoVanGoth
26 Mar 2010, 8:57 AM
Hi,

I'm trying to implement a very simple solution for sorting panels. In detail, I have a panel, which has some other panels inside. On a trigger I want to swap two of this panels (in other words, I want to remove a panel and insert it on another position) to sort one up or down.

I tried this:

var fieldcontainer = Ext.getCmp ('personsearchform_' + type + '_container');
Ext.getCmp ('personsearchformdefaultitems').remove ('personsearchform_' + type + '_container');
Ext.getCmp ('personsearchformdefaultitems').doLayout ();
Ext.getCmp ('personsearchformdefaultitems').insert (pos - 1, fieldcontainer);
Ext.getCmp ('personsearchformdefaultitems').doLayout ();

I got the error: Uncaught Error: NOT_FOUND_ERR: DOM Exception 8

But I think, the remove() destroys the entire component, making it impossible to insert it again.

So I tried remove with autodestroy set to false. Now nothing happens.

Any ideas?

Thanks!

mpawlowski
26 Mar 2010, 11:08 AM
If you check the API, calling remove on a panel returns the panel which was removed. You could try

var fieldcontainer =Ext.getCmp ('personsearchformdefaultitems').remove ('personsearchform_' + type + '_container');
Ext.getCmp ('personsearchformdefaultitems').doLayout ();
Ext.getCmp ('personsearchformdefaultitems').insert (pos - 1, fieldcontainer);
Ext.getCmp ('personsearchformdefaultitems').doLayout ();

I haven't run the code, but I think it should work.