ExtJS Portal布局问题(内部元素的自动高度/宽度)

时间:2012-03-21 12:48:55

标签: javascript extjs extjs4

我正在使用http://dev.sencha.com/deploy/ext-4.0.7-gpl/examples/portal/portal.html来构建门户网站。显然,我在其中有自定义窗口,调整其高度/宽度,如提供的链接。在其中一个窗口中,我有一个图表和一个网格,我想并排放置。但是这种方法要求我为图形提供高度/宽度。如果我这样做,如果我使用父容器的高度和宽度,图表不会调整其高度/宽度,如示例中所示。请指导我如何实现此目的。我正在使用hbox布局下来伸展。请找到以下代码。

  Ext.apply(this,{layout: {
        type: 'hbox',
        align: 'stretch'
    }
  ,      width:600,height:300,items:
     [



    {
      xtype: 'chart',
        animate: true,
        shadow: true,
        height:200,
        width:200,
        store: Ext.create('Ext.data.JsonStore', {
    fields: ['year', 'comedy', 'action', 'drama', 'thriller'],
    data: [
            {year: 2005,  action: 23890000},
            {year: 2006,  action: 38900000},
            {year: 2007,  action: 50410000},
            {year: 2008,  action: 70000000}
          ]
          }),
        legend: {
            position: 'right'
        },
        axes: [{
            type: 'Category',
            position: 'bottom',
            fields: ['action'],

        }, {
            type: 'Numeric',
            position: 'left',
            fields: ['year'],
            title: false
        }],
        series: [{
            type: 'bar',
            axis: 'top',
            gutter: 80,
            xField: 'year',
            yField: ['action'],
            tips: {

            }
        }]





          },{xtype:'grid',
    collapsible:false,store: Ext.create('Ext.data.ArrayStore', {
       fields: [
       {name: 'company'},
       {name: 'price',      type: 'float'},
       {name: 'change',     type: 'float'}
      ],
       data: myData
     }), multiSelect: true,viewConfig: {emptyText: 'No information to display'},
       columns: [{
            text     : 'Company',
            flex     : 1,
            sortable : false,
            dataIndex: 'company'
        },
        {
            text     : 'Price',
            width    : 75,
            sortable : true,
            renderer : 'usMoney',
            dataIndex: 'price'
        }]
           }]


        });

1 个答案:

答案 0 :(得分:2)

您不必在图表或网格上放置宽度/高度。只需在每个上加上'flex'值,例如flex: 1,它们在hbox容器中都具有相同的宽度。