【问题标题】:ExtJs5 How to add a floating window to a panel as an item?ExtJs5 如何将浮动窗口作为项目添加到面板中?
【发布时间】:2014-10-22 10:32:17
【问题描述】:

我正在用 MVVM 结构编写我的应用程序。我在 GeoPortal.geox.components.MapToolbar 中有按钮作为项目。在我的视图(GeoPortal.view.map.Map)中,我使用此工具栏,并且工具栏的按钮在我的视图控制器(GeoPortal.view.map.MapController)中有操作。现在这个工具栏必须是浮动的,所以我把它放在一个浮动窗口中。但要访问按钮操作,此窗口必须是面板的一个项目。

我尝试在下面的代码中添加项目,但出现此错误:

TypeError: me.floatingItems is undefined

GeoPortal.view.map.Map:

Ext.define("GeoPortal.view.map.Map",{
    "extend": "GeoPortal.geox.components.Panel",
    "controller": "map",
    "viewModel": {
        "type": "map"
    },
    "uses": ['GeoPortal.geox.components.MapToolbar',
        'GeoPortal.geox.components.MapInfobar',
        'GeoPortal.geox.components.Window'
    ],
    initComponent: function () {

        var win = Ext.create({
            xtype: 'gxWindow',
            id: 'mapToolbarWindow',
            items: [{
                xtype: 'gxMapToolbar'
            }]
        });

        // FIX this
        this.add(win);
        this.callParent();
    },

    listeners : {
        afterrender: {
            fn: function () {
                Ext.getCmp('mapToolbarWindow').show();
            }
        }
    },
    "region": 'center',
    "collapsible": false,
    "collapsed": false,
    "xtype": "mapPanel",
    items: [{
        xtype: 'gxMapInfobar'
    }, {
        html: '<div id="map" class="map"></div>'
    }]
});

提前致谢。

【问题讨论】:

    标签: javascript extjs mvvm extjs5


    【解决方案1】:

    您可以只存储对窗口this.win = Ext.create({ xtype: 'gxWindow' }) 的引用。然后,您可以在每次需要时使用。如果您还需要在窗口中引用面板,请在窗口配置中传递它:this.win = Ext.create({ xtype: 'gxWindow', panel: this })。

    另外你应该注意,你应该在面板被销毁时销毁窗口,否则你会有潜在的memleak。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2023-03-13
      • 1970-01-01
      相关资源
      最近更新 更多