【发布时间】:2011-11-22 22:52:02
【问题描述】:
我在这里有一个简单的例子,它有一个模式窗口,它是一个“视图”。我想在窗口中有一个关闭窗口的按钮,所以懒惰的用户不需要点击右上角的“X”。
我的问题是我不知道如何从控制器中引用视图。在非 MVC 世界中,我只会在按钮处理程序中执行“window.close()”。有任何想法吗?谢谢!
查看
Ext.define('AM.view.testwindow.window', {
extend: 'Ext.window.Window',
alias: 'widget.TESTwindow',
title: 'TEST Window',
layout: 'border',
width: 1000, height: 400,
minimizable: true,
maximizable: true,
closeAction: 'destroy',
initComponent: function () {
this.items = [
{xtype: 'gridpanel', region: 'center', // grid in the window
store: 'Equipments',
columns: [
{ text: 'Equip ID', dataIndex: 'EquipmentID' }
, { text: 'StationID', dataIndex: 'StationID' }
],
dockedItems: [{
xtype: 'toolbar', // Grid's toolbar
items: [
{
xtype: 'button', /* Close button to close the window */
text: 'Close Window',
itemId: 'btnTestClose'
}
]
}
]
}
];
this.callParent(arguments);
}
});
控制器
Ext.define('AM.controller.testwindow', {
extend: 'Ext.app.Controller',
stores: ['Equipments', 'Stations'],
models: ['Equipment'],
views: ['testwindow.window', 'testwindow.Grid'],
refs: [
{ ref: 'TESTgrid', selector: 'TESTgrid' },
{ ref: 'testwindow', selector: 'testwindow' }
],
init: function () {
this.control(
{
'#btnTestClose': {
click: function (butt, e, options) {
alert('close handler!');
this.getTestwindowWindowView().close(); // this fails. What should I do? ComponentQuery ?
}
}
}
)
}
}
);
按钮处理程序中“this”的范围
【问题讨论】:
标签: model-view-controller extjs view controller extjs4