PDA

View Full Version : Closing window and tab simultaneously



Ducky
01-28-2010, 10:14 AM
On my screen, if the user does not have authority to do what they are seeking to do, I grey out the screen and throw up a small window with an error message and an OK button and an X in the upper right corner. When the user clicks on the OK or the X, the window disappears but not the tab. I know that Valence sets up the tab. I saw in the Ext 3.0 API documentation that there is a Tab Panel close and a Tab Panel deactivate but I do not know the name of the Tab Panel. How can I close the tab as well?




var win = new Ext.Window({


title: 'Change Work Area',
iconCls:'application_view_detail',
closable:false,
resizable:false,
x:100,
y:150,
layout:'table',
bodyStyle: 'padding:20px',
height:100,
width:450,
items: [{
xtype: 'combo',
emptyText: 'Select the work area',
labelSeparator: ' ',
id: 'dArea',
triggerAction: 'all',
displayField: 'ARNAME',
valueField: 'ARAREA',
store: new Ext.data.JsonStore({
autoLoad: true,
url: 'vvcall.pgm',
baseParams: {
pgm: 'CHGAREA',
action: 'load'
},
root: 'MLPAREA',
fields: ['ARAREA', 'ARNAME'],
listeners: {
load: function(){
Ext.Ajax.request({
url: 'vvcall.pgm',
params: {
action: 'getdefault',
pgm: 'CHGAREA'
},
success: function(response){
var check = response.responseText;
if (check) {
var data = Ext.util.JSON.decode(response.responseText);
}
if (data.SUCCESS == '1') {
Ext.getCmp('dArea').setValue(data.ARAREA);
}
else {
Ext.Msg.alert('Error',data.MSG);
win.close();
}

richard.milone
01-28-2010, 12:49 PM
If you want to close the portal tab automatically from code, do this:

parent.tabPanelMain.remove('tab_xx')

where xx in tab_xx is the option id of the tab you want to close. You can obtain the option id by going into the options administration program, find the option you want to close, open it for editing and the top title bar will show the id number.

ktoole
01-29-2010, 12:49 PM
Can you make it clsoe the window after the person clicks the "ok" button on the alert window? Right now it closes right away.

richard.milone
01-29-2010, 02:08 PM
Try replacing your single alert line with this block. Be sure to change the tab_xx to the correct program option id.



Ext.Msg.alert('Error', data.MSG, function(btn) {
if (btn == 'ok') {
parent.tabPanelMain.remove('tab_xx')
}
});