我对ExtJS控制器有疑问。我的代码:
Ext.define('app.controller.Clients.Clients', {
extend: 'Ext.app.Controller',
stores: ['Clients.Clients'],
models: ['Clients.Clients'],
views: ['Clients.Clients'],
init: function() {
this.control({
'gridClients button[action=deleteClient]': {
click: this.onButtonClickDelete
},
'gridClients button[action=refreshClients]': {
click: this.onButtonClickRefresh
},
'gridClients button[action=printClients]': {
click: this.onButtonClickPrint
}
})
},
onButtonClickDelete: function(button, e, options) {
alert('DELETE?');
},
onButtonClickRefresh: function(button, e, options) {
alert('REFRESH?');
},
onButtonClickPrint: function(button, e, options) {
alert('PRINT?');
}
});
我将引用名为'gridClients'的网格,我想知道是否有任何方法可以在驱动程序文件中创建变量...
我将引用名为'gridClients'的网格,我想知道是否有任何方法可以在驱动程序文件中创建变量,以引用该网格。
示例,我想要类似于:
Var Grid = Ext.ComponentQuery.query (#gridClients) [0];
并像这样使用它:
OnButtonClickRefresh: function (button, e, options) {
Grid.getStore (). Load ();
}
我真的不知道在哪里声明var ...
答案 0 :(得分:1)
在控制器中,您需要使用refs
。例如:
Ext.define('app.controller.Clients.Clients', {
extend: 'Ext.app.Controller',
stores: ['Clients.Clients'],
models: ['Clients.Clients'],
views: ['Clients.Clients'],
init: function() {
...
},
refs:[{
ref:'clientsGridExample',
selector: '#gridClients'
}],
OnButtonClickRefresh: function (button, e, options) {
this // inside a controller, these functions are scoped to controller
.getClientsGridExample() // refs are automatically converted to getter methods
.getStore().load(); // Do whatever you want to do
}
});
答案 1 :(得分:0)