PDA

View Full Version : Change id of Panel



kingk
16 Dec 2010, 6:48 AM
Hi!
Is there a way to change a Panels id afterwards?
I thought about something like this:


//...
myPanel = new Ext.Panel({id:'test',...});
//some time later:
Ext.getCmp('test').id = 'newID';
//or
Ext.getCmp('test').setId('newID');
Thanks, kk

Animal
16 Dec 2010, 6:53 AM
What for?

kingk
16 Dec 2010, 7:08 AM
:D good question:
i have a "parent panel" with a button where you can add several "child panels". the id of these child panels is set in my "createChildPanel" function and indexed from 1..n ('id-1', 'id-2',...). after deleting of one of theses childes i can't iterate over the id's, because there might be an id missing. so i want to reset the id's if a child is deleted.

kingk
16 Dec 2010, 7:09 AM
example:
5 child panels:
'id-1', 'id-2', 'id-3', 'id-4', 'id-5'

after deleting the panel with id 'id-3':
'id-1', 'id-2', 'id-4', 'id-5'

but i want them to be:
'id-1', 'id-2', 'id-3', 'id-4'

kingk
22 Dec 2010, 2:02 AM
so no possibility to change the id?

mankz
22 Dec 2010, 2:19 AM
I wouldn't change the id, it's bound to cause trouble. Better to create your own variable "myId" and tamper with it anyway you want:



myPnl.myId = 'foo';

kingk
22 Dec 2010, 2:23 AM
sounds reasonable!
thanks mankz

kingk
22 Dec 2010, 2:38 AM
hm, there is a resulting problem:
i am searching for the components in a for loop


for(i=0;i<size;i++)
Ext.getCmp('id-'+i);

If i use a custom parameter in the Panel i think i can't reference the panel by it?