我有一個簡單的例子,這裏是一個'視圖'的模式窗口。我想在窗口內有一個窗口關閉窗口,所以懶惰的用戶不需要點擊右上角的'X'。Extjs 4.0 MVC - 如何關閉控制器內的視圖?
我的問題是我不知道如何從控制器內引用視圖。在非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 ?
}
}
}
)
}
}
);
範圍
是的......昨晚想通了。我認爲引用只是訪問組件的簡短方式,但實際上它們允許硬件引用組件。感謝您的回答! – amackay11