简体   繁体   English

如何在extJS的面板中打开网格?

[英]How can I open a grid in a panel in extJS?

I want to open a grid in Ext.Panel . 我想在Ext.Panel打开一个网格。 This is what I tried- 这就是我尝试的

Var grid = Ext.create('Ext.grid.Panel', {
store: Ext.data.StoreManager.lookup('StoreId'),
columns: [
    { header: 'Resort', dataIndex: 'resort' },
    { header: 'Arrival', dataIndex: 'arrival' },
    { header: 'Guest', dataIndex: 'guest', flex: 1 }
]
renderTo: Ext.getBody()
});

Var panel = new Ext.Panel({
title: 'Accompanying Guest(s)',  
id: 'panel',    
items: [grid]
});

And I want to open this panel in a window - 我想在一个窗口中打开此面板-

var win = new Ext.Window({
                    layout: 'fit',
                    width: 900,
                    height: 600,
                    closeAction: 'hide',
                    plain: true,
                    items: [panel]
                });

Whats wrong in my code? 我的代码有什么问题?

var win = new Ext.Window({
    autoShow: true,
    layout: 'fit',
    width: 900,
    height: 600,
    closeAction: 'hide',
    plain: true,
    items: [{
        xtype: 'gridpanel',
        title: 'Accompanying Guest(s)',
        store: Ext.data.StoreManager.lookup('StoreId'),
        columns: [{
            header: 'Resort',
            dataIndex: 'resort'
        }, {
            header: 'Arrival',
            dataIndex: 'arrival'
        }, {
            header: 'Guest',
            dataIndex: 'guest',
            flex: 1
        }]
    }]
});

Where do I start... 我从哪里开始...

  1. Don't use renderTo if you're putting an item inside a container. 如果要将项目放入容器中,请不要使用renderTo。
  2. You've given the panel a border layout with a center region. 您已为面板提供了带有中心区域的边框布局。
  3. The border layout isn't necessary, using fit will do. 边框布局不是必需的,使用fit即可。
  4. You've declared dimensions on the grid, but they will be provided by the fit layout. 您已经在网格上声明了尺寸,但是尺寸将由合适的布局提供。
  5. Over-nesting. 过度嵌套。 The grid ~is a~ panel, there's no point nesting it inside another panel. 网格是一个面板,将点嵌套在另一个面板中是没有意义的。 Put the title on the grid panel itself. 将标题放在网格面板本身上。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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