我想问我可以在哪里向网格MVC添加侦听器。
当我这样做时,什么都没有发生:
Ext.define('myApp.view.reslist' ,{
extend: 'Ext.grid.Panel',
alias : 'widget.reslist',
store : 'resStore',
listeners: {
activate: {
fn: function(e){
console.log('reslist panel activated');
}
}
},
dockedItems: [{
xtype: 'pagbar',
store: 'resStore',
dock: 'top',
displayInfo: true
}],
..... rest of grid configs
并且适用于click事件:
listeners: {
activate: {
fn: function(e){
console.log('reslist panel clicked');
}
}
}
注意:我的控制器的init仍然是空的:
Ext.define('myApp.controller.resControl', {
extend: 'Ext.app.Controller',
stores: ['resStore'],
models: ['resModel'],
views: ['reslist','pagbar'],
init: function() {
// nothing here
}
});
Ext.define('myApp.controller.resControl', {
extend: 'Ext.app.Controller',
stores: ['resStore'],
models: ['resModel'],
views: ['reslist','pagbar'],
init: function() {
this.control({
'reslist' : {
activate: function(e) {
alert('reslist panel activated');
}
}
});
}
});
注意,仅当使用选项卡面板显示时,才会在面板上调用激活事件。当通过单击选项卡激活面板时,将调用该事件。