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

  • 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
主站蜘蛛池模板: 桃江县| 朝阳区| 三亚市| 台湾省| 乐业县| 松滋市| 鲁山县| 清远市| 新源县| 延津县| 肥乡县| 应城市| 洪湖市| 威远县| 皮山县| 陇川县| 林州市| 汾阳市| 北碚区| 当涂县| 县级市| 平顺县| 嘉鱼县| 永定县| 廉江市| 临城县| 惠州市| 黄平县| 浦北县| 白银市| 河津市| 玉溪市| 韶关市| 陕西省| 兰坪| 咸丰县| 茌平县| 交城县| 南华县| 大新县| 宜黄县|