I am using the 2010.3 controls and adding tabs programmatically on the client-side. I now have a need to "close" the tabs, but I am not able to find a method to do this. Is there a way to accomplish this, I can't do a postback for many reasons and need to be able to totally remove the tab client side.
Thanks for the feedback, sadly in our case "hiding" isn't an option. The page that contains the tab control NEVER posts back and has viewstate disabled for the entire page.
You can think of the tab control in this instance as a shell for an application.
Hi Mitchel,
Removing tab items on client is not supported for several reasons. Besides tabItem object by itself there are also, transactions and viewstates, which are passed to server. Unexpected changes or states may trigger exceptions. Even if you remove TabItem object from its collection, there are still tab-label, content pane of tab item, map which defines order of visible indexes, etc.
I do not recommed to use any methods or objects which starts with the "_" until there is no alternatives. To hide a tab, instead of _closeTab, please use public method
tabItem.set_hidden(true);
I found a solution to this, but I want to know if there is a "better" way to handle this, as it feels VERY dirty.
function closeCurrentTab() { var tabControl = $find(tabControlClientId); var currentIndex = tabControl.get_selectedIndex(); //Move to new tab, then close the current tabControl.set_selectedIndex(0); tabControl._closeTab(tabControl.getTabAt(currentIndex)); //Cleanup items that infragistics doesn't! tabControl._tabs.splice(currentIndex, currentIndex); tabControl._itemCollection._items.splice(currentIndex, currentIndex); }
With this though I have a new issue.
Yes, this will "close" the tab, but it appears to still be in the collection. If I try to "add" a tab again with the same name and contentUrl, it will display, but it isn't in the tab list for navigation.
I need to COMPLETELY remove the tab from the collection, do you know if/how this is possible
Lyuba,
THANK YOU!
Sorry for the confusion, I did not see a separate forum for "WebTab" and in the description of this forum it said to use this to discuss WebTab, thus the post being put here.