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

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

Using the table layout

If you have remained faithful to HTML tables, then you are in luck! Ext JS provides a layout manager—TableLayout—whose basic building concept is conceptually similar to building an HTML table.

This is how you can create a complex table layout with cells that span multiple rows or columns. In the following screenshot, you'll see what the end result looks like:

Using the table layout

How to do it...

  1. The table cells are built as follows:
    c1={ title: 'A cell', html: '<p>colspan=1<br/>rowspan=1</p>' }
    // This cell spans 2 columns.
    c2={ title: 'A cell', html: '<p>colspan=2<br/>rowspan=1</p>', colspan: 2 }
    // This cell spans 3 rows.
    c3={ title: 'A cell', html: '<p>colspan=1<br/>.<br/>.<br/>.<br/>. 
    <br/>.<br/>.<br/>.<br/>.<br/>.<br/>rowspan=3</p>', rowspan: 3 }
    c4={ title: 'A cell', html: '<p>rowspan=3<p>' }
    // This cell spans 2 rows.
    c5={ title: 'A cell', html: 'colspan=1<br/>.<br/>.<br/>.<br/> rowspan=2</p>', rowspan: 2 }
    c6={ title: 'A cell', html: '<p>colspan=4<p>' }
    c7={ title: 'A cell', html: '<p>colspan=4<p>' }
    // This cell does not have the panel header.
    c8={ html: 'Plain cell' }
    
  2. The cells are added to their container. Notice the layout:'table' configuration option:
    var container=new Ext.Viewport({
    layout: 'table',
    defaults: {
    bodyStyle: 'padding:10px'
    },
    layoutConfig: {
    columns: 4
    },
    items: [c1,c2,c3,c4,c5,c6,c7,c8]
    });
    

How it works...

The code starts by creating the table cells, which are panel components. Note how you can use the colspan and rowspan configuration options of each cell to build a layout as complex as you need.

These cells are added to their container, which uses a table layout specified through the layout configuration option. Additionally, the number of columns is passed via the layoutConfig object.

There's more...

TableLayout is useful when you need a rich, grid-like structure for your components. This layout figures out how to position each panel within the table based on the column count, rowspans, and colspans. Be mindful that, as with the HTML tables, rowspans and colspans should add up correctly in the overall layout.

See also...

  • The previous recipe, Positioning components in multiple columns, illustrates how to display complex data or have an organized and easy-to-navigate GUI using columns
主站蜘蛛池模板: 靖远县| 梓潼县| 锦屏县| 祥云县| 大悟县| 新竹市| 开封市| 惠水县| 伊春市| 郁南县| 大连市| 南召县| 合川市| 香格里拉县| 泾阳县| 木里| 灌阳县| 隆昌县| 潮州市| 马关县| 峨边| 宝鸡市| 专栏| 保定市| 石林| 灵石县| 克什克腾旗| 龙岩市| 习水县| 济南市| 舒城县| 长宁区| 酉阳| 贵阳市| 竹山县| 集安市| 苗栗市| 德江县| 滨海县| 从江县| 清水河县|