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

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

Positioning components in multiple columns

Multicolumn layouts are pervasive today. They are a favorite choice when there is a need to display complex data, or to have an organized and easy-to-navigate GUI. This recipe explains how to set up this type of layout with Ext JS, as shown in the following screenshot:

Positioning components in multiple columns

How to do it...

  1. Create the columns of your layout:
    var column1={
    xtype:'panel',
    title: 'Column 1',
    columnWidth: .3,
    html: 'Width=30%'
    }
    var column2={
    xtype: 'panel',
    title: 'Column 2',
    columnWidth: .5,
    html: 'Width=50%'
    }
    var column3={
    xtype: 'panel',
    title: 'Column 3',
    width: 200,
    html: 'Width=200px'
    }
    
  2. Position the columns in a container that uses the column layout:
    var container=new Ext.Viewport({
    layout: 'column',
    defaults: {
    bodyStyle: 'padding:10px'
    }, items: [column1, column2, column3]
    });
    

How it works...

Building a column layout requires you to create the panels that will constitute the columns. These columns are then added to a container that uses ColumnLayout. (Note the use of the layout:'column' configuration option.)

There's more...

In a column layout, the width of each column can be specified as a percentage or fixed width, but the height is allowed to vary, based on the content. The percentage width is set via the columnWidth configuration property, which is included in the config object of any panel added to it.

The specific rules about setting column widths can be found in the Ext JS documentation at http://extjs.com/deploy/dev/docs/?class=Ext.layout.ColumnLayout.

Note

Note that the concept of rows is absent in this layout. If you need precise control over the horizontal alignment of components across columns, you need to consider using a table layout.

See also...

  • The following recipe, Using the table layout illustrates how to lay out components in multiple rows or columns
主站蜘蛛池模板: 农安县| 南涧| 辽宁省| 瓮安县| 定结县| 阿合奇县| 防城港市| 合阳县| 临高县| 平定县| 新竹县| 三原县| 晋中市| 长垣县| 孟连| 汝南县| 安塞县| 府谷县| 南康市| 明光市| 夏河县| 香港 | 乌鲁木齐市| 武川县| 牡丹江市| 仁化县| 乃东县| 南华县| 宝坻区| 延长县| 临海市| 安福县| 宁武县| 拉孜县| 南和县| 濮阳县| 庆城县| 宁海县| 松原市| 巴东县| 台前县|