如何从 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/