How to get application from view?

Afshin Mehrabani picture Afshin Mehrabani · Jan 2, 2013 · Viewed 10.1k times · Source

How can I get my application from a view? For example consider I have an application Boo and there's a view that named Boo.view.Foo.List and I want to get Boo in the view List.

Edit:

See this code, and look at the line 20.

Ext.define('Boo.view.Foo.List', {
    extend: 'Ext.panel.Panel',
    model: 'Boo.model.FooModel',
    alias: 'widget.foolist',
    store: 'FooListStore',
    initComponent: function () {
        this.columns = [
            {
                text: "Hello world",
                dataIndex: 'Time',
                flex: 1
            },
            {
                xtype: 'actioncolumn',
                width: 50,
                items: [{
                    icon: 'cancel.png',
                    tooltip: 'Cancel',
                    handler: function (grid, rowIndex, colIndex, col, e) {
                        //Now I need to get the application here, for example with self.getApplication() or something like this.
                    }
                }]
        }];

        this.callParent(arguments);
    }
});

Answer

sra picture sra · Jan 2, 2013

You can archieve this using the appProperty

Ext.application({
    name: 'MyApp',
    appProperty: 'Current'
});

You can now call

MyApp.Current

from anywhere cause the MyApp namespace resist within the window (global) scope.

For any Version before 4.1.3 add the following line to the Launch-Method of the Application

YourAppName[this.appProperty] = this;