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

  • Ext JS 3.0 Cookbook
  • Jorge Ramon
  • 508字
  • 2021-04-01 13:43:49

Creating a modern application layout with collapsible regions

This layout is very popular in modern applications where the GUI consists of multiple nested panels with split bars and collapsible regions. Here's a sample that you can use as a foundation for your applications as seen below:

Creating a modern application layout with collapsible regions

How to do it...

  1. Set up the panels of the application:
    northPanel={
    title: 'North Panel',
    region: 'north',
    height: 150,
    minSize: 75,
    maxSize: 250,
    cmargins: '0 0 5 0'
    }
    southPanel={
    title: 'South Panel',
    region: 'south',
    height: 150,
    minSize: 75,
    maxSize: 250,
    cmargins: '5 0 0 0'
    }
    westPanel={
    title: 'West Panel',
    region: 'west',
    margins: '0 0 0 0',
    cmargins: '0 5 0 0',
    width: 175,
    minSize: 100,
    maxSize: 250
    }
    eastPanel={
    title: 'East Panel',
    region: 'east',
    margins: '0 0 0 0',
    cmargins: '0 0 0 5',
    width: 175,
    minSize: 100,
    maxSize: 250
    }
    centerPanel={
    title: 'Center Panel',
    collapsible: false,
    region: 'center',
    margins: '0 0 0 0'
    }
    
  2. Now, build the container and add the panels to it:
    var container=new Ext.Viewport({
    layout: 'border',
    defaults: {
    collapsible: true,
    split: true,
    bodyStyle: 'padding:15px'
    },
    items: [northPanel, southPanel,
    westPanel, eastPanel, centerPanel
    ]
    });
    
    

How it works...

When creating this complex layout, you first need to decide on the configuration for each of your panels: what region each panel will belong to, which panels will be collapsible, and what will be the panel margins when expanded and when collapsed.

When it comes to putting the panels in their container, the layout that you must use is Ext.layout.BorderLayout.

There's more...

The regions of a BorderLayout are fixed at render time. Thereafter, no regions may be removed or added. Be mindful that a BorderLayout must have a center region, which will always fill the space that is not used up by the other regions in the layout.

Border layouts are very popular in modern applications due to the efficient use of space that can be achieved in the GUI. They also contribute to having well-defined interface areas that encapsulate elements that work together to perform a piece of functionality.

Examine how you can use nested border layouts to divide the West Panel into two separate regions, as shown in the following screenshot:

There's more...

Firstly, set up the two panels that will make up the two regions within the West Panel:

nestedPanel1={
region: 'north',
height: 150
}
nestedPanel2={
region: 'center'
}

Observe how nestedPanel2 is assigned to the center region, so it fills the space not used by nestedPanel1.

As the final step, modify the West Panel by adding the nested panels, and configure its layout as a BorderLayout:

westPanel={
title: 'West Panel',
region: 'west',
margins: '0 0 0 0',
cmargins: '0 5 0 0',
width: 175,
minSize: 100,
maxSize: 250,
bodyStyle:'border:0px',
layout: 'border',
defaults: {
collapsible: true,
split: true,
bodyStyle: 'padding:15px'
},
items:[nestedPanel1,nestedPanel2]
}

See also...

  • The recipe, Wizard-style UI using a card layout (seen previously in this chapter), illustrates how to create a Wizard to lead the user through multiple steps
  • The previous recipe, Using the table layout, explains how to lay out components in multiple rows or columns
主站蜘蛛池模板: 石门县| 同心县| 佳木斯市| 阿尔山市| 察哈| 旺苍县| 长葛市| 宁化县| 海伦市| 张掖市| 漯河市| 郁南县| 凯里市| 基隆市| 常德市| 隆尧县| 望江县| 咸阳市| 梧州市| 邢台市| 建始县| 灵丘县| 兴业县| 兴文县| 贵南县| 睢宁县| 斗六市| 天长市| 金坛市| 临海市| 沅陵县| 绥阳县| 呈贡县| 隆昌县| 呼伦贝尔市| 安顺市| 化州市| 张家界市| 阳西县| 富裕县| 丰县|