【问题标题】:extjs gridpanel inside a panel not autoscroll or resize面板内的extjs gridpanel不会自动滚动或调整大小
【发布时间】:2012-08-12 23:19:13
【问题描述】:

我有一个标签面板。在选项卡中,我有一个面板,其中包括一个工具栏和 3 个项目:[ 字段集、网格面板和另一个字段集(或一些按钮)]。我无法让网格面板显示滚动条。它仅在我设置网格面板的最大高度/最小高度时才有效。
我还尝试将网格面板包装在容器中。没有运气。 在示例中,我使用适合布局。我尝试了“锚”布局,并将锚:'100%50%'分配给网格面板,希望在我调整浏览器大小时它会调整大小。没有运气。

或者,如果 gridpanel 是选项卡中的唯一项目,则自动滚动将起作用。所以它出现在另一个面板内时,自动滚动/调整大小不起作用。

我在这里错过了什么吗?

Ext.application({
    name: 'MyApp',
    launch: function () {

        // create the data store
        var d = ['company', 100];
        var myData = [];
        for (var i = 0; i < 50; i++) {
            myData[i] = d;
        }
        var store = Ext.create('Ext.data.ArrayStore', {
            fields: [{
                name: 'company'
            }, {
                name: 'price',
                type: 'float'
            }],
            data: myData
        });

        Ext.create("Ext.container.Viewport", {
            layout: {
                type: 'border'
            },
            items: [{
                xtype: 'toolbar',
                id: 'headerbar',
                region: 'north',
                height: 30
            }, {
                xtype: 'toolbar',
                id: 'menubar',
                region: 'north',
                height: 30
            }, {
                xtype: 'tabpanel',
                itemId: 'maintabpanel',
                activeTab: 0,
                region: 'center',
                plain: true,
                margins: '5 5 5 5',
                layout: 'fit',
                items: [{
                    closable: false,
                    title: 'Tab',
                    margins: '0 0 0 0',
                    items: [{
                        xtype: 'panel',
                        title: 'Panel',
                        layout: 'fit',
                        tools: [{
                            type: 'help',
                            tooltip: 'Help'
                        }, {
                            type: 'close',
                            tooltip: 'Close'
                        }],
                        items: [{
                            xtype: 'fieldset',
                            title: 'Field Set',
                            layout: 'hbox',
                            items: [{
                                xtype: 'textfield',
                                fieldLabel: 'Input'
                            }]
                        }, {
                            xtype: 'gridpanel',
                            autoScroll: true,
                            store: store,
                            columns: [{
                                text: 'Company',
                                flex: 1,
                                sortable: true,
                                dataIndex: 'company'
                            }, {
                                text: 'Price',
                                flex: 1,
                                sortable: true,
                                dataIndex: 'price'
                            }],
                            viewConfig: {
                                autoFit: true
                            }
                        }, {
                            xtype: 'fieldset',
                            title: 'Field Set 2',
                            layout: 'hbox',
                            items: [{
                                xtype: 'textfield',
                                fieldLabel: 'Output'
                            }]
                        }]

                    }]
                }]
            }, {
                xtype: 'box',
                id: 'footer',
                region: 'south',
                html: '<h1> Copyright 2012</h1>',
                height: 30
            }]
        });
    }
});

【问题讨论】:

  • 您找到解决问题的方法了吗?

标签: extjs extjs4


【解决方案1】:

请注意,网格面板的父面板具有fit 布局,但它有多个项目(字段集、网格面板和另一个字段集)。 fit 布局只能有 1 个孩子。

另外,fit 面板的父级(带有closable : false - 选项卡的面板)没有布局定义。

这是一个有效的JsFiddle modified version of your code

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2012-08-29
    • 1970-01-01
    • 2013-02-19
    • 1970-01-01
    • 2014-06-13
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多