View Full Version : Controling tab from within a tab
David Grossi
2 Jan 2010, 11:13 PM
Hello all,
I've a new enigma today.
I have a Domino page opened in a tab of an Ext tabPanel.
This Domino page contains common javascript.
Now, I "just" would like this javascript to be able to close the tab with a button.
My problem is that this Domino code is "outside" of the context of Ext, and doesn't know anything of the tabPanel and the tab object.
A simple "window.close()" doesn't have any effect on my tab, and I wonder if it's possible to close this tab from "outside" of Ext context.
Any idea would be welcomed.
Best regards.
Dear David,
Try parent.ExtndApp.ui.tabPanel.remove(parent.ExtndApp.ui.tabPanel.activeTab);:>
jratcliff
4 Jan 2010, 9:26 AM
I have a Domino page opened in a tab of an Ext tabPanel.
What does this code look like? The code that opens the domino page in an Ext TabPanel?
David Grossi
4 Jan 2010, 9:53 AM
The code that opens my Domino page is... your code ;-)
I explain : I'm using your default Ext.nd.DominoUI object to build the very basic layout that you know very well : outline on the left, which opens views on the right, which open documents in new tabs.
Now, the documents opened in tabs are using basic Notes forms with some javascript inside, but this javascript doesn't use Ext / Ext.nd.
How to make this javascript "communicate" with its container object (the ext.nd tab) ?
I've just tried the solution mentionned by R.J (thanks to him) :
parent.ExtndApp.ui.tabPanel.remove(parent.ExtndApp.ui.tabPanel.activeTab)
Without success...
I've tried Firebug to check at my page DOM model in order to find where I could "branch" some code, but I don't see how to catch this Extndapp object.
I think I've said everything (and maybe too much).
Thank you.
markroberts906
4 Jan 2010, 11:34 AM
Hi David,
You can try something like this... I wish I could credit where I got this, but I honestly can't recall if it was from demos in Ext or from these forums somewhere but I know I borrowed and modified slightly for an app we use.
function closeTab()
{
//Close the actived tab
var oExt = window.parent.Ext;
var centerPanel = oExt.getCmp('center-region');
centerPanel.remove(centerPanel.activeTab,true);
oExt.getCmp('view-location').refresh();
};
center-region is the id of my tabpanel in this example, so you may need to modify that to match your use. I also am doing a view refresh on the last line, you can omit that if you do not need.
Hopefully this helps some, I know it works for me however your mileage may vary. :)
Good luck and happy coding.
-Mark
jratcliff
5 Jan 2010, 10:33 AM
You can use the code that markroberts906 posted if you gave your TabPanel and id. Or you can use this function that should run on a page that does not have Ext loaded on your domino page/form.
Code for closing a page/form that was loaded in a tabpanel
function closeTab() {
var target = window.target;
var activeTab = target.getActiveTab();
target.remove(activeTab);
}
again, this will only work if you let Ext.nd open your page/form since Ext.nd will add the target property to the loaded page. Also, this is assuming that you are letting Ext.nd open the page/form into a tab on a tabpanel. If your UIView has a target property to, say an Ext.Window, then you will need to get a handle to the target (which will be the Ext.Window) and then call the Ext.Window's close or hide method.
Code for closing a page/form that was loaded in an Ext.Window
function closeWindow() {
var target = window.target;
if (target.closeAction == 'close') {
target.close();
} else {
target.hide();
}
}
Jack
David Grossi
5 Jan 2010, 12:59 PM
Hello Jack and Markroberts,
Thank you very much for your fast answers. I've been busy and could not test yet these options. I'll perform new tests tomorrow and will give you my feedback. I still can't believe how kind everyone is, here. It's really a great point for ext / ext.nd ! \:D/
Powered by vBulletin® Version 4.1.5 Copyright © 2012 vBulletin Solutions, Inc. All rights reserved.