PDA

View Full Version : [RESOLVED] : How to change dynamicly an element in a Panel



Yohann
19 Jan 2011, 3:26 AM
I guys, I try to change the second element of a panel by another.
Here is my Panel :


var mainPanel = new Ext.Panel(
{
id : 'mainPanel',
title : 'TITRE',
renderTo : 'tree-div',
layout: 'border',
width:1000,
height:400,
items : [monArbre, panneauVide]
});
My TreePanel is the first Element called 'monArbre' and 'panneauVide' is the Panel I want to remove and replace by another Panel.

Here is the code of the Panel I try to inject.



var myReplacementPanel = new Ext.Panel({
id:'emptyPanel2',
title:'Détail d\un élément',
region:'center',
margins: '5 5 5 0',
layout:'fit',
html: '<div id="myForm"><p>VIDE2</p></div>'
});
Ext.getCmp('mainPanel').remove('emptyPanel'); works correctly and the empty Panel on the right part disappears.
But if I try to do that :


Ext.getCmp('mainPanel').insert(1, myReplacementPanel);
Nothing changes, no error.

Any idea.
Thanks

Condor
19 Jan 2011, 3:43 AM
You can't. Border layout doesn't support adding or removing components.

I recommend using another panel with layout:'fit' as your west region and put the tree in it.

Yohann
24 Jan 2011, 6:06 AM
Thanks it's perfect.