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

  • Ext JS 3.0 Cookbook
  • Jorge Ramon
  • 302字
  • 2021-04-01 13:43:48

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
主站蜘蛛池模板: 江都市| 贺兰县| 北川| 滨州市| 德清县| 余江县| 托克托县| 遂昌县| 宁陕县| 双峰县| 墨江| 嘉善县| 武隆县| 黄浦区| 南皮县| 会泽县| 韶关市| 彰化市| 马鞍山市| 博罗县| 沙湾县| 慈溪市| 太原市| 临澧县| 集安市| 临高县| 宁都县| 鲁山县| 色达县| 花莲县| 隆林| 黑龙江省| 静海县| 兰西县| 九龙坡区| 刚察县| 平江县| 武义县| 巢湖市| 郓城县| 教育|