-
25 Sep 2008 4:50 AM #1
Howto Add/Remove (dynamically) Tabs from TabPanel
Howto Add/Remove (dynamically) Tabs from TabPanel
Hi
Adding tabs dynamically to a TabPanel is pretty easy..
http://extjs.com/deploy/dev/examples/tabs/tabs-adv.html
However removing them isn't (if you dont know the ids of the tabs)
I would have thought you just could iterate over items on the tabpanel, but you cant, because (if you use firebug) the array is "empty"...
if you inspect the panel in firebug you can see that you would to do something like this panel.items.items, to get tabs.. (notice, this still wont help to remove items because it is "empty")
So how is this suppose to be done?
-
25 Sep 2008 5:08 AM #2Sencha - Community Support Team
- Join Date
- Mar 2007
- Location
- Frederick MD, NYC, DC
- Posts
- 16,169
- Vote Rating
- 28
tabPanel.remove(someTab, true);
tabPanel.add(someNewTab);
tabPanel.setActiveTav(someNewTab);
Jay Garcia @ModusJesus || Modus Create co-founder
Ext JS in Action author
Sencha Touch in Action author
Get in touch for Ext JS & Sencha Touch Touch Training
We are also working on Video-based Sencha Touch training: Check it out here.
-
25 Sep 2008 5:21 AM #3
Thanks, but i still need af piece of the puzzle
i need to get someTab, from the tabPanel, before i can do this tabPanel.remove(someTab, true);
and when you cant iterate items on tabPanel and dont know the Ids, then you have a "no go".
-
25 Sep 2008 5:40 AM #4
You must know something about the Panel that you want to remove, because you know you want to remove something.
Search the forum: http://www.google.com/coop/cse?cx=01...%3Az7of1ufqccu
Read the docs too: http://extjs.com/deploy/dev/docs/
Scope: http://extjs.com/forum/showthread.ph...642#post257642
-
25 Sep 2008 5:55 AM #5
I know that i have a panel and that i have added tabs at one point...
However i could store the tabs in an array while adding them to the panel, because then i would something about the tabs later on... but that wouldn't be "pretty"!
I would think that the right way to this problem would be that items on tabpanel actually worked, so i would just iterate over it and do
panel.items.each(function(item){
panel.remove(item)
})
-
25 Sep 2008 6:27 AM #6
So you want to remove them all? That code above will work.
Search the forum: http://www.google.com/coop/cse?cx=01...%3Az7of1ufqccu
Read the docs too: http://extjs.com/deploy/dev/docs/
Scope: http://extjs.com/forum/showthread.ph...642#post257642
-
25 Sep 2008 7:52 AM #7
except that items is considered to be empty for some reason, even though the tabs are their..
yes, i wanna remove them all
-
25 Sep 2008 7:55 AM #8Sencha - Community Support Team
- Join Date
- Mar 2007
- Location
- Frederick MD, NYC, DC
- Posts
- 16,169
- Vote Rating
- 28
try:
(it should work with panel.items.each);
Code:Ext.each(panel.items.items, function(childPanel) { panel.remove(childPanel, true); });
Jay Garcia @ModusJesus || Modus Create co-founder
Ext JS in Action author
Sencha Touch in Action author
Get in touch for Ext JS & Sencha Touch Touch Training
We are also working on Video-based Sencha Touch training: Check it out here.
-
25 Sep 2008 7:57 AM #9
SHoujld work just fine.Code:myTabPanel.items.each(function(c){myTabPanel.remove(c);})Search the forum: http://www.google.com/coop/cse?cx=01...%3Az7of1ufqccu
Read the docs too: http://extjs.com/deploy/dev/docs/
Scope: http://extjs.com/forum/showthread.ph...642#post257642
-
26 Sep 2008 12:59 AM #10
you are right, it works.. i dont know why it didn't work for me in the begining..
and when i saw that items where empty in firebug
console.log(tabPanel.items) -> []
then i thought something where wrong... even though it works now, it just makes it even more confusing to get the above result in firebug


Reply With Quote