6

ビューからアプリケーションを取得するにはどうすればよいですか?たとえば、アプリケーションBooがあり、名前が付けられたビューがあり、そのビューにアクセスしBoo.view.Foo.ListたいとしBooますList

編集:

このコードを見て、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);
    }
});
4

1 に答える 1

10

appPropertyを使用してこれをアーカイブできます

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

これで電話できます

MyApp.Current

どこからでもMyApp、ウィンドウ(グローバル)スコープ内で名前空間が抵抗します。

4.1.3より前のバージョンの場合は、アプリケーションのLaunch-Methodに次の行を追加します

YourAppName[this.appProperty] = this;
于 2013-01-02T10:49:29.677 に答える