0

一度に2つのPanelインスタンスを作成できるようにしたいのですがnew Dashboard.NotificationPanel(); new Dashboard.NotificationPanel();、最初のインスタンスのようなことをすると、グリッド結果が表示されません。私はそれが何らかの形でinitComponentステージに関連していると思います、特に両方のオブジェクトは参照によって同じストアオブジェクトを使用します。私が間違っている場合は訂正するか、間違いを指摘してください。前もって感謝します。

Dashboard.NotificationPanel = Ext.extend(Ext.grid.GridPanel, {
    columns: [...],
    view: new Ext.grid.GridView({
        forceFit: true,
        enableRowBody: true,
        ignoreAdd: true,
        emptyText: 'No Notifications to display'
    }),
    initComponent: function () {
        var store = new Ext.data.Store({
            url: '...',
            autoLoad: true,
            reader: new Ext.data.XmlReader({
                record: 'result',
                id: 'id'
            }, ['c_case_number', 'c_creator', 'c_date_created', 'c_notification_condition', 'c_message'])
        });
        var config = {
            store: store,
            bbar: new Ext.PagingToolbar({
                pageSize: 10,
                store: store,
                displayInfo: true,
                displayMsg: 'Displaying notifications {0} - {1} of {2}',
                emptyMsg: "No Notifications to display"
            })
        }
        Ext.apply(this, Ext.apply(this.initialConfig, config));

        Dashboard.NotificationPanel.superclass.initComponent.call(this);

    }

});
4

1 に答える 1

3

2つのインスタンスで機能しない理由は、グリッドの実際のインスタンスではなく、ビューと列がプロトタイプに適用されているためです。これらは基本的に、予期されない動作であるすべてのインスタンス間で共有されています。共有動作が必要でない限り、プロトタイプに非プリミティブオブジェクトを配置しないでください。代わりにこのようなことをしてください:

Dashboard.NotificationPanel = Ext.extend(Ext.grid.GridPanel, {
initComponent : function() {
    var store = new Ext.data.Store({
        url : '...',
        autoLoad : true,
        reader : new Ext.data.XmlReader({
                    record : 'result',
                    id : 'id'
                }, ['c_case_number', 'c_creator', 'c_date_created',
                        'c_notification_condition', 'c_message'])
    });
    var config = {
        columns : [...],
        view : new Ext.grid.GridView({
            forceFit : true,
            enableRowBody : true,
            ignoreAdd : true,
            emptyText : 'No Notifications to display'
        }),
        store : store,
        bbar : new Ext.PagingToolbar({
                    pageSize : 10,
                    store : store,
                    displayInfo : true,
                    displayMsg : 'Displaying notifications {0} - {1} of {2}',
                    emptyMsg : "No Notifications to display"
                })
    }
    Ext.apply(this, Ext.apply(this.initialConfig, config));

    Dashboard.NotificationPanel.superclass.initComponent.call(this);

}
});

また

Ext.apply(this, Ext.apply(this.initialConfig, config))

代わりにExt3の冗長コードです:

Ext.apply(this, config)
于 2012-04-07T03:24:58.030 に答える