admin管理员组文章数量:1384595
var tabPanel = Ext.getCmp('tabPanel');
for(var i=1; i<tabPanel.items.length; i++)
{
tabPanel.items.removeAt(i);
i--;
}
tabPanel.doLayout();
I'm trying to remove all the tabs (except the first one) from the tabPanel.
This code is doing that. I checked it using firebug.
But still, it is not reflecting in the UI.
Isn't doLayout() enough?
var tabPanel = Ext.getCmp('tabPanel');
for(var i=1; i<tabPanel.items.length; i++)
{
tabPanel.items.removeAt(i);
i--;
}
tabPanel.doLayout();
I'm trying to remove all the tabs (except the first one) from the tabPanel.
This code is doing that. I checked it using firebug.
But still, it is not reflecting in the UI.
Isn't doLayout() enough?
2 Answers
Reset to default 4Instead of calling
tabPanel.items.removeAt(i);
Call
tabPanel.remove(tabPanel.items.getAt(i));
Then you're telling the container instead of the mixed collection to remove the tab
Another way to do it is
tabPanel.removeChildEls(function(tab){
return tab != tabPanel.items.first();
});
This closes a tab by clicking the middle button of your mouse.
var middleClick = $(document).mousedown(function(e) {
if(e.which == 2){
var tabPanel = <%= tabPanel.ClientID %>;
var activeTab = tabPanel.getActiveTab();
if (e.target.textContent == activeTab.title) {
var activeTabIndex = tabPanel.items.findIndex('id', activeTab.id);
tabPanel.remove(activeTabIndex);
}
}
return true;
});
Hope it helps!! =)
本文标签: javascriptRemoving a tab from tabPanelStack Overflow
版权声明:本文标题:javascript - Removing a tab from tabPanel - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1744537212a2611388.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论