简体   繁体   English

如何添加功能以创建窗口extjs4?

[英]how to add function to create a window extjs4?

my application is web desktop using 4.2 extjs. 我的应用程序是使用4.2 extjs的Web桌面。 i just want to add my window a controller so that i can create a MVC but i cant figure out how to add the controller. 我只想向我的窗口添加一个控制器,以便我可以创建MVC,但我不知道如何添加控制器。 Here's my code. 这是我的代码。 The win variable is always undefined. win变量始终是未定义的。 how to fix it.? 如何解决。 please help 请帮忙

Ext.define('MyDesktop.Modules.Itemmanagement.Client.Itemmanagement', {
    requires: ['Ext.tab.Panel',
        'Ext.ux.CheckColumn'],
    id: 'itemmanagement-win',
    init: function () {
        var me = this;

        this.launcher = {
            text: 'Itemmanagement Module ',
            iconCls: 'icon-itemmanagement',
            handler: this.createWindow,
            scope: this
        };

    },
    createWindow: function () {
        var me = this;
        var desktop = this.app.getDesktop();
        var win = desktop.getWindow('itemmanagement-win');
        if (!win) {
            Ext.application({
                name: 'USER',
                appFolder: '/modules/',
                controllers: [
                    "User"
                ],
                launch: function () {
                    win = desktop.createWindow({
                        id: 'itemmanagement-win',
                        title: 'Item Management',
                        width: 600,
                        height: 505,
                        iconCls: 'icon-itemmanagement',
                        animCollapse: false,
                        constrainHeader: true,
                        layout: 'fit'
                    });
                }
            });
        }
        win.show();
        return win;
    }
});

Create the window in your current application and don't create a new application. 在当前应用程序中创建窗口,不要创建新的应用程序。

createWindow: function () {
    var me = this;
    var desktop = this.app.getDesktop();
    var win = desktop.getWindow('itemmanagement-win');
    if (!win) {
        win = desktop.createWindow({
            id: 'itemmanagement-win',
            title: 'Item Management',
            width: 600,
            height: 505,
            iconCls: 'icon-itemmanagement',
            animCollapse: false,
            constrainHeader: true,
            layout: 'fit'
        });
    }
    win.show();
    return win;
}

Define a controller in your controller folder (eg app/controller/ItemmanagementWindow.js ). 在您的控制器文件夹中定义一个控制器(例如app/controller/ItemmanagementWindow.js )。 Add it to your controller section in your Application. 将其添加到“应用程序”中的控制器部分。 Call in the init function this.control() with component queries you are interested and listen to the events. 使用您感兴趣的组件查询调用init函数this.control()并监听事件。

Ext.define('MyDesktop.controller.ItemmanagementWindow',{
    extend: 'Ext.app.Controller',

    init: function(){
        this.control({
           // selector of window we want to add listeners to
           '#itemmanagement-win' : {
               // events we listen to
               afterrender: this.onAfterRender
           } 
        });
    },

    // handler function of the afterrender event
    onAfterRender: function(window, eOpts){
        //do some stuff in the after render event ...
    }
});

See Application , ComponenQueries and MVC architecture for more informations 有关更多信息,请参见ApplicationComponenQueriesMVC体系结构

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

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