2012-05-11 93 views
0

有什么办法可以将应用程序扩展到另一个应用程序的mdi? 例如。我有3个应用程序:“Transaction”,“SalesOrder”&“PurchaseOrder” 我想通过在“SalesOrder”&“PurchaseOrder”中扩展它来重复使用“Transaction”。 什么是干净的方式来做到这一点?Extjs 4扩展应用程序的mdi

回答

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"); 
    } 
}); 
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();