extjs - 如何从 View 中获取应用程序?

标签 extjs extjs-mvc

如何从 View 中获取我的应用程序?
例如考虑我有一个应用程序 Boo并且有一个名为 Boo.view.Foo.List 的 View 我想得到 Boo在 View 中 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);
    }
});

最佳答案

您可以使用 对此进行存档。 appProperty

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

你现在可以打电话
MyApp.Current

从任何地方导致 MyApp命名空间抵抗在窗口(全局)范围内。

对于 4.1.3 之前的任何版本,将以下行添加到应用程序的 Launch-Method
YourAppName[this.appProperty] = this;

关于extjs - 如何从 View 中获取应用程序?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14120649/

相关文章:

javascript - ExtJS5 如何让keymap调用viewController函数?

extjs - 如何设置 Ext Grid 过滤器默认值?

sencha-touch - Sencha Touch itemtap

javascript - 获取函数调用者的范围

extjs - 网格-按钮单击处理程序

extjs - extjs4 mvc 中基于角色的 View

php - 当单击树面板中的节点时,事件选项卡会在 extjs 4 的选项卡面板中重新加载

javascript - 调试在 Firefox 中不起作用 - Firebug

Extjs 4 禁用 PagingToolbar 的工具提示