PDA

View Full Version : Hiding tab



iyeh
5 Nov 2009, 6:53 AM
How do I hide tab?

The following code doesn't work.


import com.extjs.gxt.ui.client.widget.LayoutContainer;
import com.extjs.gxt.ui.client.widget.TabItem;
import com.extjs.gxt.ui.client.widget.TabPanel;

public class TabExample extends LayoutContainer {

private TabPanel contentPanel = new TabPanel();

public TabExample() {
}

@Override
protected void beforeRender() {
super.beforeRender();

contentPanel.setSize(400, 300);

TabItem item1 = new TabItem("Tab 1");
item1.setVisible(false);

TabItem item2 = new TabItem("Tab 2");

contentPanel.add(item1);
contentPanel.add(item2);
add(contentPanel);
}
}

Yuppy
9 Sep 2010, 12:19 PM
I have the same problem, but I found a solution. Try this:


tab.getHeader().addStyleName("tab-hidden");


Css style:


.tab-hidden {
display: none;
}

sven
9 Sep 2010, 12:21 PM
The easiest would probably be to remove the TabItem from the TabPanel and add it again if needed.

Yuppy
9 Sep 2010, 12:44 PM
Yes, but sometimes we need to add TabItem in the same index, where TabItem was placed before. Also if we want to hide TabItem, it must be already attached to TabPanel. In my situation, where I'm creating tabs dynamically, add and remove css style is the simpliest way to hide and show tabs, with or without attaching them before to TabPanel.

sven
9 Sep 2010, 12:46 PM
adding/removing css or adding/removing tabitems should be just the same.


Also if we want to hide TabItem, it must be already attached to TabPanel.
If it is not added, than you dont ahve to hide it.


Yes, but sometimes we need to add TabItem in the same index, where TabItem was placed before.
Your controler/presenter could safe the index.

Yuppy
9 Sep 2010, 1:00 PM
If it is not added, than you dont ahve to hide it.

Of course, but I need to set TabItem visibility before attach it to TabPanel.



Your controler/presenter could safe the index.

But this way need some refactoring in existing application, so adding and removing style is simplier.