doucha7329 2014-12-08 05:51
浏览 56

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

my application is web desktop using 4.2 extjs. 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. Here's my code. The win variable is always undefined. 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;
    }
});
  • 写回答

1条回答 默认 最新

  • duanmeng2842 2014-12-09 13:34
    关注

    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 (e.g. 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.

    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

    评论

报告相同问题?

悬赏问题

  • ¥100 set_link_state
  • ¥15 虚幻5 UE美术毛发渲染
  • ¥15 CVRP 图论 物流运输优化
  • ¥15 Tableau online 嵌入ppt失败
  • ¥100 支付宝网页转账系统不识别账号
  • ¥15 基于单片机的靶位控制系统
  • ¥15 真我手机蓝牙传输进度消息被关闭了,怎么打开?(关键词-消息通知)
  • ¥15 装 pytorch 的时候出了好多问题,遇到这种情况怎么处理?
  • ¥20 IOS游览器某宝手机网页版自动立即购买JavaScript脚本
  • ¥15 手机接入宽带网线,如何释放宽带全部速度