Extjs tabpanel limit the number of tabs Implementation ideas and code

Source: Internet
Author: User

Copy codeThe Code is as follows:
Var tabIndex = 'shouye ';
Var tabIndex2 = 'shouye ';
Var tabIndex3 = 'shouye ';
Var tabIndex4 = 'shouye ';
Var tabIndex5 = 'shouye ';
Var tabIndex6 = 'shouye ';
Var tabIndex7 = 'shouye ';
/**
* Add a window to the TabPanel component or activate an existing window.
* Load the specified resource into the window.
* @ Param node: the input Node
*/
Var loadPanel = function (node ){
Var id = node. id; // obtain the node id
TabIndex7 = id;
Var href = node. attributes. href; // obtain the href attribute of the node.
Var text = node. text;
Var mainPanel = Ext. getCmp ('mainpanel ');
// MainPanel. remove ('mainpanel ', true );
Var qtip = node. attributes. qtip;
Var tab = mainPanel. getComponent (String (id); // gets the Component Object of the specified id
If (tab ){
MainPanel. setActiveTab (tab); // check whether the current Tab exists. If it exists, you only need to activate it.
Return;
}
// If the tab does not exist, the code for creating the tab is as follows:
Tab = mainPanel. add (new Ext. Panel ({
// Create a new tab Configuration
Id: String (id), // Set ID, which must be forcibly converted to the string type
Title: text, // set the tab title
TabTip: text,
Html: '<iframe width = 100% id = main_desk name = main_desk height = 100% frameborder = 0 scrolling = auto src =' + href + '/> ',
AutoScroll: true,
EnableTabScroll: true,
Defaults: {autoScroll: true },
Closable: true // whether it can be disabled
}));
MainPanel. setActiveTab (tab); // after creating a tab, activate it.
MainPanel. remove (tabIndex, true );
TabIndex = tabIndex2;
TabIndex2 = tabIndex3;
TabIndex3 = tabIndex4;
TabIndex4 = tabIndex5;
TabIndex5 = tabIndex6;
TabIndex6 = tabIndex7;
}

The variable storage id is used to swap the id when loading the new selected card, thus limiting the number of opened tabs. If this effect is not required, we recommend that you do not close and create tabpanel frequently.

Related Article

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.