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

  • 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
主站蜘蛛池模板: 那曲县| 南开区| 建昌县| 宜兰市| 宁武县| 子洲县| 金湖县| 烟台市| 都兰县| 全州县| 大方县| 武鸣县| 广昌县| 荃湾区| 东方市| 左权县| 辽中县| 廉江市| 仪陇县| 凌海市| 金寨县| 留坝县| 扎赉特旗| 舞钢市| 保靖县| 卢龙县| 南京市| 汝阳县| 南城县| 重庆市| 朝阳区| 长白| 金平| 柞水县| 禄劝| 门源| 仙游县| 枝江市| 阜城县| 通化县| 英超|