extjs gridpanel不显示滚动条

发布于 2024-12-28 22:51:16 字数 1454 浏览 3 评论 0原文

我正在创建一个仅包含网格面板的页面,我希望我的网格面板具有基于浏览器大小的滚动条。为此,我将其包装在视口中,如所讨论的 在这里并确保我指定了所讨论的布局此处。网格渲染得很好,但我没有看到任何滚动条。我尝试过“适合”、“边框”和“锚定”布局,但仍然没有成功。代码如下所示:

Ext.create('Ext.Viewport', {
    items: [{
        region: 'center',
        layout: 'fit',
        xtype: 'gridpanel',
        store: myStore,
        loadMask: true,      
        columns: [{
            header: 'Account ID',
            dataIndex: 'acct_id',
            width: 70
        }, {
            header: 'First Name',
            dataIndex: 'first_name',
            width: 120
        }, {
            header: 'Last Name',
            dataIndex: 'last_name',
            width: 120
        }, {
            xtype: 'numbercolumn',
            header: 'Account Balance',
            dataIndex: 'acct_bal',
            width: 70,
            renderer: Ext.util.Format.usMoney
        }, {
            xtype: 'numbercolumn',
            header: 'Credit',
            dataIndex: 'credit',
            width: 70,
            renderer: Ext.util.Format.usMoney
        }, {
            xtype: 'numbercolumn',
            header: 'Debt',
            dataIndex: 'debt_bal',
            width: 70,
            renderer: Ext.util.Format.usMoney
        }],
    }]
});

I am creating a page that only contains a gridpanel, I want my gridpanel to have scrollbars based on the browser size. To do this I am wrapping it in a viewport as discussed here and making sure I specify a layout as discussed here. The grid renders fine but I am not getting any scroll bars. I've tried 'fit', 'border' and 'anchor' layouts but still no luck. The code looks like this:

Ext.create('Ext.Viewport', {
    items: [{
        region: 'center',
        layout: 'fit',
        xtype: 'gridpanel',
        store: myStore,
        loadMask: true,      
        columns: [{
            header: 'Account ID',
            dataIndex: 'acct_id',
            width: 70
        }, {
            header: 'First Name',
            dataIndex: 'first_name',
            width: 120
        }, {
            header: 'Last Name',
            dataIndex: 'last_name',
            width: 120
        }, {
            xtype: 'numbercolumn',
            header: 'Account Balance',
            dataIndex: 'acct_bal',
            width: 70,
            renderer: Ext.util.Format.usMoney
        }, {
            xtype: 'numbercolumn',
            header: 'Credit',
            dataIndex: 'credit',
            width: 70,
            renderer: Ext.util.Format.usMoney
        }, {
            xtype: 'numbercolumn',
            header: 'Debt',
            dataIndex: 'debt_bal',
            width: 70,
            renderer: Ext.util.Format.usMoney
        }],
    }]
});

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

温馨耳语 2025-01-04 22:51:16

您应该将 fit 布局设置为 Viewport

Ext.create('Ext.Viewport', {
    layout: 'fit',
    items: [...]
});

GridPanel 中设置布局无效。

You should set fit layout to Viewport:

Ext.create('Ext.Viewport', {
    layout: 'fit',
    items: [...]
});

Setting layout in GridPanel have no effect.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文