官术网_书友最值得收藏!

Using a tabbed look

A tabbed GUI is modeled on the traditional card tabs or card indexes. It makes your screens easier to understand and navigate, and gives the application a more natural look. This recipe helps you to build a panel with three tabs, as shown in the following screenshot:

Using a tabbed look

How to do it...

  1. Create the tabs. Each tab is simply a Ext.Component, such as a panel:
    var tab1={
    title: 'First Tab',
    html: 'Content for the first tab'
    };
    var tab2={
    title: 'Second Tab',
    html: 'Content for the second tab'
    };
    var tab3={
    title: 'Third Tab',
    html: 'Content for the third tab'
    };
    
  2. What's left is to put the tabs in their containers:
    var tabPanel=new Ext.TabPanel({
    title: 'Tab Panels',
    width: 400,
    height: 300,
    applyTo: 'tab-panel',
    // Each tab is just a panel managed by the card layout.
    items: [tab1, tab2, tab3],
    activeItem: 0,
    defaults: {bodyStyle:'padding:5px'}
    });
    

How it works...

After you build your tabs, use an Ext.TabPanel as their container. The TabPanel class displays one tab at a time using the CardLayout layout manager.

There's more...

When using TabPanel, each child component fires events that only exist for tabs: activate and deactivate.

Tab panels can also be rendered from pre-existing markup, either already structured as a TabPanel, or from different elements within the page by ID, regardless of page structure. For example, based on the following markup:

<div id="my-tabs" style="width:400px;margin:10px;"></div>
<div id="tab1" class="x-hide-display" style="height:200px">A simple tab</div>
<div id="tab2" class="x-hide-display" style="height:200px">Another one</div>

You need to add the following code to create a tab panel similar to the one in the next screenshot:

var tabPanel=new Ext.TabPanel({
renderTo: 'my-tabs',
activeTab: 0,
items: [
{ contentEl: 'tab1', title: 'Tab 1' },
{ contentEl: 'tab2', title: 'Tab 2' }
]
});
There's more...

See also...

  • The previous recipe, Wizard-style UI using a card layout, explains how to create a Wizard to lead the user through multiple steps
主站蜘蛛池模板: 彰武县| 合水县| 格尔木市| 勃利县| 玛曲县| 孟津县| 金山区| 巴青县| 林甸县| 桂东县| 井陉县| 湖州市| 峡江县| 融水| 贡觉县| 福泉市| 宕昌县| 若羌县| 临西县| 平潭县| 长宁区| 仪征市| 密山市| 隆林| 贵州省| 龙胜| 景宁| 邳州市| 绥芬河市| 霍邱县| 南昌县| 平原县| 杭州市| 凤庆县| 湘阴县| 陈巴尔虎旗| 新河县| 信宜市| 临沭县| 呼和浩特市| 仪陇县|