PDA

View Full Version : how to close a panel



rex0098
1 May 2011, 7:33 PM
hello everyone i have the following code that i want to use



var tableTest = {
id:'main-panel',
layout:'table',
layoutConfig: {columns:6},
defaults: {
frame:true,
width:162,
height: 122,
fbar:[{
iconCls: 'tb_close',
handler: ???????
}]
},
items: []
}

function itemsForTable(){
var x = 3;
for(i=1;i<=x;i++)
{
var v = Ext.getCmp('main-panel');
v.add({
xtype:'panel',
title:'Room'+i,
html:'this is room '+i,
id:'Rm'+i,
name:'Rm'+i
})
v.doLayout();
}

}



when i click the button the code above will create three panels on my table layout and each of them will have a button inside that can be clicked to close a panel. my problem are:
* how can i create a handler function for the button that when clicked it will close the panel it is assigned to.
*how to get the exact id of the panel i want to close when i click the button insede it.

please help me guys....need it badly....:(

drian
1 May 2011, 9:52 PM
you're saying "...and each of them will have a button inside that can be clicked to close a panel"... but i'm not seeing any buttons being created.

When you create a panel, create a close button also where you can do a simple .destroy() and .doLayout().

rex0098
1 May 2011, 10:50 PM
i used an fbar to create the button and made it a default in "tableTest" so that every newly created panel may have a button. i also used a for loop to give each panel different ids. my question is if i run my program then i hit a button which will give me 3 newly created panels each with close button and with different ids,how can i make a handler function that can get the id of the panel that i want to destroy when i click the close button inside it?

pmatsumura
1 May 2011, 11:36 PM
Take a look at createDelegate found here (http://dev.sencha.com/deploy/ext-3.3.1/docs/?class=Ext.util.Functions)