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

ExtJS Portal layout issue (auto height/width of internal elements)

本文关键字:高度 宽度 元素 布局 问题 内部 ExtJS      更新时间:2023-09-26

我正在使用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'
        }]
           }]

        });

您不应该在图表或网格上设置宽度/高度。只需在每个上加一个"flex"值,例如flex: 1,使它们在hbox容器中具有相同的宽度。