PDA

View Full Version : one child - multiple parents - possible?



johnrembo
14 May 2010, 1:36 AM
Hi,

I've been experimenting with large grid sets and have realized that i.e. different panels can not contain similar items (references, rather than separate copies of an object) without extra-logic applied (such as panel0.remove(grid), panel1.add(grid))

Below is an example to ilustrate my problem:

Ext.onReady(function(){

var navHandler = function(direction){
card.layout.setActiveItem(direction);
};

//preferred solution
var bt1=new Ext.Button({text:'btn1'});
var bt2=new Ext.Button({text:'btn2'});
var bt3=new Ext.Button({text:'btn3'});

//working solution
function bt(t){return new Ext.Button({text:t})};

var card = new Ext.Panel({
id:'tstPanel',
title: 'Example Wizard',
layout:'card',
renderTo:'cont',
activeItem: 0,
width:200,
height:150,
bodyStyle:'padding:10',
layoutOnCardChange:true,
deferredRender:true,
defaults: {
border:false,
xtype:'buttongroup'
},
bbar: [{
text: 'Back',
handler: navHandler.createDelegate(this, ['card-0']),
},{
text: 'Next',
handler: navHandler.createDelegate(this, ['card-1'])
}],
items: [{
id: 'card-0',
title:'card-0',
html:'card-0',
//items:[bt('bt1'),bt('bt2'),bt('bt3')] //working solution
items:[bt1,bt2,bt3] //preferred not-working solution
},{
id: 'card-1',
title:'card-1',
html:'card-1',
//items:[bt('bt1')] //working solution
items:[bt1] //preferred solution
}]
});

})


I the example above I'm seeking in having the same button ("btn1") to be available in two different panels
http://img718.imageshack.us/img718/3294/ok1w.jpg http://img189.imageshack.us/img189/7134/ok2z.jpg
Unfortunately - this seems to be only possible by creating copies of it

Otherwise - we'll end up with "btn1" being attached to the last panel it was configured for
http://img156.imageshack.us/img156/1623/prob1.jpg http://img210.imageshack.us/img210/2197/prob1a.jpg

Before applying some logic to move items across panels I just wanted to ask if there's no an easy way of solving this? (some config option, an extension or else)

below is an example of what i'm trying to achieve
http://img268.imageshack.us/img268/6606/cardlayoutproblem.gif

Thank You

Zdeno
14 May 2010, 6:54 AM
Why do you need move panels ( grids ) between different panels? Isnt better to create grids on every card and on click/dblclick event just set up store base params and reload the store? Dont forget you still create a lot of element ... check it on IE... dont waste your resources. I know everything is fine when you got 1,2,3.. 10 elements... but try to remove and add 100..1000 element.