Extjs 4扩展了mdi的应用程序

时间:2012-05-11 06:02:02

标签: extjs4 mdi extend

有没有办法将应用程序扩展到另一个mdi应用程序? 对于前者我有3个应用程序:“Transaction”,“SalesOrder”& “采购订单” 我希望通过在“SalesOrder”和“SalesOrder”中扩展它来重用“Transaction”。 “采购订单” 。 什么是干净的方式呢?

2 个答案:

答案 0 :(得分:1)

您只需定义一个具有特定名称的application,然后再定义extend

BaseApp.js

Ext.application({
    name: 'BaseApp',
    launch: function () {
        alert("Base App Launch");
    }
});

ChildApp.js

Ext.application({
    //extend from base app
    extend: 'BaseApp',
    name: 'ChildApp',
    launch: function () {
        alert("Child App Launch");
    }
});

答案 1 :(得分:0)

是的,因为ExtJS 4.2可能。

http://docs.sencha.com/extjs/4.2.2/#!/api/Ext.app.Application

检查文档部分'从Ext.app.Application派生'

这是一个小例子:

Ext.define('Transaction.Application', {
    extend: 'Ext.app.Application',
    requires: [],

    // application namespace
    name: 'Transaction',

    // name of the app instance in DOM (e.g. Transaction.instance)
    //appProperty: 'instance',

    // application folder
    appFolder: '/js/Transaction',

    autoCreateViewport: true,

    controllers: [
    ],

    views: [
    ],

    launch: function() {
        console.log('application started');
    }
});

Ext.define('SalesOrder.Application', {
    extend: 'Transaction.Application',
    requires: [],

    // application namespace
    name: 'SalesOrder',

    // application folder
    appFolder: '/js/SalesOrder',

    autoCreateViewport: false,

    controllers: [
    ],

    views: [
    ],

    launch: function() {
        Ext.create('Ext.container.Viewport');
        this.callParent();
    }
});

Ext.define('PurchaseOrder.Application', {
    extend: 'Transaction.Application',
    requires: [],

    // application namespace
    name: 'PurchaseOrder',

    // application folder
    appFolder: '/js/PurchaseOrder',

    autoCreateViewport: false,

    controllers: [
    ],

    views: [
    ],

    launch: function() {
        Ext.create('Ext.container.Viewport');
        this.callParent();
    }
});

Ext.application('PurchaseOrder.Application');

// Then you can acces your application instance anywhere:
var app = PurchaseOrder.getApplication();