ExtJs2.0 Learning Series (a)--ext.tabpanel the second type

Source: Internet
Author: User
Tags autoload

The last one we have a simple understanding of the next TabPanel

Below we want to introduce is, how to add the tab page dynamically!

2. Dynamically add a TabPanel label page

Effect Chart:

Clicking on "Add new tab" will add a tab and activate the New tab page.

HTML code:

<body style= "margin:10px;" >
<div>
<a id= "Addnewtab" href= "javascript:void (0)" > Add new Tab </a>
</div>
</body>

JS Code:

Ext.onready (function () {
Ext.QuickTips.init ();
var tabsdemo=new ext.tabpanel ({
RenderTo:Ext.getBody (),
activetab:0,
height:700,
Frame:true,
items:[{
Title: "AutoLoad for HTML Simple page demo",
Autoload:{url: "Tab1.htm", scripts:true}
}]
});
Here is the key code to add a new tab, very simple and convenient
var index=0;
Ext.get ("Addnewtab"). On ("click", Function () {
Tabsdemo.add ({
Title: "Newtab",
ID: "Newtab" +index,
HTML: "New Tab",
Closable:true
});
Tabsdemo.setactivetab ("Newtab" +index);
index++;
})
});

Simple description:

Actually add, as long as the Add () method is OK, but we also want to activate the new tab, we must SetActiveTab (Newtab index or ID), the key is that we do not judge the index, So we have to set an incremental global variable index to give Newtab name, so we can accurately obtain new newtab, also easy to activate. And we can see it through the figure below.

3. Slightly revise the above example TabPanel (official example)

Effect Chart:

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.