3

私は ExtJS4 で作業しています。ボーダー レイアウトの東の領域を自動高さにしたいところに行き詰まりました。実際、私の要件は、その中の子要素のコンテンツに基づいて、任意の領域の高さを自動的に増やすことです。私はたくさん試しましたが、解決策が得られませんでした。何か提案をください。

私のコードでは、東地域に 5 つのパネルを含む単純なコードをテストしているだけで、これらの 4 つのパネルのうち表示されます。5 番目のパネルが表示されないのですが、表示するにはどうすればよいですか? 参考までにサンプルコードを使用しています。

これが私のビューポートコードです:

Ext.define('Am.view.Viewport', {
    extend: 'Ext.container.Viewport',
    layout: 'border',
    id:'viewportId',
    alias:'widget.Viewport',
    autoScroll:true,

       //        closable:true,
               items: [
                       {
                           region:'north',
                                       items:[
                                  {
                                      xtype:'panel',
                                      flex:.2,
                                      title:'north region',
                                      html:'<p>north region'
                                  }

                                  ]//end of items

                       },
                       {
                           region:'west',
                           id:'westId',
                           //margins:'0 5 5 5',
                           flex:.3,
                           //layout:'accordion',
                           items:[
                                              {
                                      title:'This day in a history',
                                      xtype:'Content'
                                  }

                                  ]//end if items
                       },// end of region west
                       {
                           //title:'center',
                           region:'center',
                           id:'centerId',
                           //html:'center region',
                           items:[
                                  ]//End of itmes
                       },// end of region center
                       {
                           region:'east',
                           id:'eastId',
                           //margins:'0 5 0 5',
                           flex:.3,
                           //layout:'accordion',
                           items:[
                                  {
                                      xtype:'panel',
                                      title:'panel1',
                                      html:'hi<br>hello<br>good<br><br><br><br><br>morning<br>nice<br>looking',
                                  },
                                  {
                                      xtype:'panel',
                                      title:'panel2',
                                      html:'hi<br>hello<br>good<br><br><br><br<br>noon<br>nice<br>looking',
                                  },
                                  {
                                      xtype:'panel',
                                      title:'panel3',
                                      html:'hi<br>hello<br>good<br><br><br><br><brafter noon<br>nice<br>looking'
                                  },
                                  {
                                      xtype:'panel',
                                      title:'panel4',
                                      html:'hi<br>hello<br>good<br><br><br><br><br><br><brnigth<br>nice<br>looking'
                                  },
                                  {
                                      xtype:'panel',
                                      title:'panel5',
                                      html:'good bye'
                                  },
                                  ]//end if items
                       },
                       {
                           //title:'South',
                           region:'south',
                           id:'southId',
                           items:[{
                                  xtype:'panel',
                                  title:"footer",
                                  html:'footer '
                           }]
                       },//mainMenu   // used mainMenu when you are using mainMenu variable
                       ]//end if items
});//End of view port

そして、ここに私のスクリーンショット出力があります: ここに画像の説明を入力

子コンポーネント panel5 は表示されません。どうすれば見えるようにできますか?この要件を持つすべてのパネルを表示するにはどうすればよいですか? パネルのコンテンツに基づいて、東の領域のサイズを自動的に大きくしたいと考えています。
何か提案をください。

4

3 に答える 3

6

コンテンツに基づいてパネルを自動サイズ変更するには

その値を 0 に設定し、flex他のパネルの値がflex0 と異なることを確認する必要があります。したがって、次のコードでは、フッターには がflex: 0あり、中央領域にはflex: 1;があります。したがって、フッターはその内容に基づいてサイズ変更されます。これは動作中のJsFiddleです:

Ext.create('Ext.panel.Panel', {
    width: 500,
    height: 300,
    title: 'Border Layout',
    layout: 'border',
    items: [{
        title: 'Footer',
        region:'south',
        xtype: 'panel',
        margins: '5 0 0 5',
        flex: 0, // Notice this.
        id: 'footer',
        layout: {
            type: 'vbox',
            align : 'stretch',
            pack  : 'start',
        },
        items:[{
            title: '1',
            height: 50
        },{
            title: '2',
            height: 50                                   
        }]
    },{
        title: 'Center Region',
        flex: 1, // Notice this.
        region: 'center',
        xtype: 'panel',
        layout: 'fit',
        margins: '5 5 0 0'
    }],
    renderTo: Ext.getBody()
});

Ext.getCmp('footer').add({
    title: '3',
    height: 50                        
});

コンテンツに基づいてスクロールする固定サイズのパネルを取得するには

autoScroll: trueコンテナー (領域パネル)を追加するだけです。

この JsFiddleで実際に動作するコードを次に示します。

Ext.create('Ext.panel.Panel', {
    width: 500,
    height: 300,
    title: 'Border Layout',
    layout: 'border',
    items: [{
        title: 'West Region',
        region:'west',
        xtype: 'panel',
        margins: '5 0 0 5',
        width: 200,
        id: 'west-region-container',

        // Notice the next line
        autoScroll: true,
        layout: {
            type: 'vbox',
            align : 'stretch',
            pack  : 'start',
        },
        items:[{
            title: '1',
            height: 100
        },{
            title: '2',
            height: 100            
        },{
            title: '3',
            height: 100                        
        }]
    },{
        title: 'Center Region',
        region: 'center', 
        xtype: 'panel',
        layout: 'fit',
        margins: '5 5 0 0'
    }],
    renderTo: Ext.getBody()
});
于 2013-03-24T21:13:19.863 に答える
0

flex構成設定を検索しています:

    items:[{
        title: 'panel1',
        flex: .3
    },{
        title: 'panel2',
        flex: .3
    },{
        title: 'panel3',
        flex: .4
    }]
于 2013-03-25T06:59:28.547 に答える
0

これは機能します(少なくとも最初の問題では):

    Ext.define('MyApp.view.ui.MyViewport', {
    extend: 'Ext.container.Viewport',

    layout: {
        type: 'border'
    },

    initComponent: function() {
        var me = this;

        Ext.applyIf(me, {
            items: [
                {
                    xtype: 'container',
                    region: 'center'
                },
                {
                    xtype: 'panel',
                    width: 150,
                    title: 'My Panel',
                    region: 'west'
                },
                {
                    xtype: 'container',
                    width: 150,
                    layout: {
                        align: 'stretch',
                        type: 'vbox'
                    },
                    region: 'east',
                    items: [
                        {
                            xtype: 'panel',
                            title: 'My Panel',
                            flex: 1
                        },
                        {
                            xtype: 'panel',
                            title: 'My Panel',
                            flex: 1
                        },
                        {
                            xtype: 'panel',
                            title: 'My Panel',
                            flex: 1
                        },
                        {
                            xtype: 'panel',
                            title: 'My Panel',
                            flex: 1
                        },
                        {
                            xtype: 'panel',
                            title: 'My Panel',
                            flex: 1
                        }
                    ]
                },
                {
                    xtype: 'panel',
                    height: 50,
                    title: 'My Panel',
                    region: 'north'
                },
                {
                    xtype: 'panel',
                    height: 50,
                    title: 'My Panel',
                    region: 'south'
                }
            ]
        });

        me.callParent(arguments);
    }
});

ここに画像の説明を入力

于 2013-03-25T19:48:09.527 に答える