How to get application from view?

杀马特。学长 韩版系。学妹 提交于 2020-02-23 09:57:09

问题


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

回答1:


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;


来源:https://stackoverflow.com/questions/14120649/how-to-get-application-from-view

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!