solarissf
solarissf

Reputation: 1277

extjs6 popup window, error on second time I launch window

In my extjs6 project I have a contextmenu button that I launch a modal popup window with a grid inside. I tried to create it so it only creates the component once, and that window isn't created everytime I click the contextmenu item but I am doing something wrong.

It works the first time, but when I click it the second time I get an error CANNOT READ PROPERTY 'viewModel' of null.

Can someone see what I am doing wrong?

the error appears when I get to this.tempWindow.show()

VIEW, window is popup window, grid is where the itemcontext menu is located

Ext.define('Window2', {
extend: 'Ext.window.Window',
xtype: 'window2',
title: 'Market Breakdown',
width: 600,
height: 600,
modal: true,
controller: 'portalRealtime-portalRealtime',
viewModel: {
    type: 'portalRealtimeVM'
},
items: [{
    xtype: 'grid',
    title: 'hello',
    width: 200,
    height: 200
}]
});

            xtype: 'grid',
            title: 'Details',
            itemId: 'detailsGridID',
            bind: {
                store: '{myDetailsStore}'
            },           
            flex: 3,
            margin: '5px 0px 0px 0px',
            ui: 'featuredpanel-framed',
            cls: 'custom-grid',
            height: '100%',
            collapsible: true,
            collapseDirection: 'left',
            listeners: {
                itemcontextmenu: 'showContextMenuDetails'
            },

CONTROLLER

   showContextMenuDetails: function (view, rec, node, index, e) {
    e.stopEvent();
    this.getContextMenuDetails(rec).show().setPagePosition(e.getXY());
    return false;
},

getContextMenuDetails: function (rec) {
    if (!this.contextMenu) {
        this.contextMenu = this.getView().add({
            xtype: 'contextMenuMarketDrilldownAccount',
            currentRecord: rec
        });
    }
    return this.contextMenu;
},

onContextButtonMarketDrilldown: function (item, e) {

    var menu = item.up('menu');
    var rec = menu.currentRecord;
    var bbSymbol = rec.get('BBSymbol');

    debugger;
    if (!this.tempWindow) {
        this.tempWindow = this.getView().add({
            xtype: 'window2',
        });
    }
    this.tempWindow.show();
},

Upvotes: 0

Views: 180

Answers (1)

Daniel da Cunha Bueno
Daniel da Cunha Bueno

Reputation: 156

Try put viewModel and controler atributes properly configured with your controller and viewModel.

Ext.define('Window2', {
    extend: 'Ext.window.Window',
    xtype: 'window2',
    title: 'Market Breakdown',
    width: 600,
    height: 600,
    modal: true,
    viewModel: {
        type: 'Window2' //Yout window viewModel
    },
    controller: 'Window2',    //Your window controller,
    items: [{
        xtype: 'grid',
        title: 'hello',
        width: 200,
        height: 200
    }]
});

Upvotes: 1

Related Questions