简体   繁体   中英

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

I am using http://dev.sencha.com/deploy/ext-4.0.7-gpl/examples/portal/portal.html to build a portal. Obviously, i have custom windows inside it that adjust their height/width as in the provided link. In one of the windows i have got a chart and a grid that i want to place side by side in a row. But this approach requires me to provide height/width for graph.If i do this the chart doesnt adjust its height/width if i play with the height and width of parent container as in the example.Please guide how can i accomplish this.I am using hbox layout with alight to stretch. Please find the code below.

  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'
        }]
           }]


        });

You shouldn't have to put a width/height on the chart or grid. Just put a 'flex' value on each, eg, flex: 1 for them both to have the same width in the hbox container.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM