Ext JS - 多次创建相同的网格是行不通的

时间:2011-11-24 05:56:49

标签: extjs extjs4 multiple-instances

我已经定义了一个新类“ConfirmationPanel”,我想在窗口内创建这个面板。我第一次创建窗口时显示正常。但是当我创建第二个窗口时,window-1中的面板移动到window-2。我想为每个窗口创建两次相同的面板。我怎么能这样做?

Ext.define('MyApp.views.ConfirmationPanel', {
    extend: 'Ext.grid.Panel',
    requires: 'MyApp.store.ConfirmationStore',
    border: false,
    initComponent: function() {
        this.store = Ext.create('MyApp.store.ConfirmationStore', {});
        this.columns = this.buildColumns();
        this.callParent(arguments);
    },
    buildColumns: function() {
        return [
            {text: "Id", width: 50, flex: 1, dataIndex: 'docId', sortable: true},
            {text: "Name", width: 150, dataIndex: 'docName', sortable: true},
            {text: "Type", width: 75, dataIndex: 'docType', sortable: true},
            {text: "URL", width: 115, dataIndex: 'docUrl', sortable: true},
            {text: "Sent Time", width: 115, dataIndex: 'docSentTime', sortable: true},
            {text: "Ack Time", width: 115, dataIndex: 'docAckTime', sortable: true}
        ];
    },
    viewConfig: {
        listeners: {
            itemdblclick: function( dataview, record, item, index, e) {
                alert( 'opening document here');
            }
        }
    }
});

Ext.define('MyApp.views.ConfirmationPanel', { extend: 'Ext.grid.Panel', requires: 'MyApp.store.ConfirmationStore', border: false, initComponent: function() { this.store = Ext.create('MyApp.store.ConfirmationStore', {}); this.columns = this.buildColumns(); this.callParent(arguments); }, buildColumns: function() { return [ {text: "Id", width: 50, flex: 1, dataIndex: 'docId', sortable: true}, {text: "Name", width: 150, dataIndex: 'docName', sortable: true}, {text: "Type", width: 75, dataIndex: 'docType', sortable: true}, {text: "URL", width: 115, dataIndex: 'docUrl', sortable: true}, {text: "Sent Time", width: 115, dataIndex: 'docSentTime', sortable: true}, {text: "Ack Time", width: 115, dataIndex: 'docAckTime', sortable: true} ]; }, viewConfig: { listeners: { itemdblclick: function( dataview, record, item, index, e) { alert( 'opening document here'); } } } });

感谢任何帮助/建议。

----我试图在tabpanel中创建一个新的面板实例。但即便如此,它只创建了一个实例。可能是我做了一些基本上错了。

1 个答案:

答案 0 :(得分:0)

Ext.define('MyApp.views.ConfirmationPanel', {
    ...
    alias: 'confirmpanel',
    ...

和tabpanel内部:

        {
            title:'My Confirms',
            items: [{
                xtype: 'confirmpanel'
            }]
        }

您获得此类行为的原因是因为在您通过Ext.create(“MyApp.views.ConfirmationPanel”)进行设置期间创建了MyApp.views.ConfirmationPanel的唯一一个实例