使用extjs控制器

使用extjs控制器,extjs,Extjs,我有一个关于ExtJS控制器的问题。我的代码: Ext.define('app.controller.Clients.Clients', { extend: 'Ext.app.Controller', stores: ['Clients.Clients'], models: ['Clients.Clients'], views: ['Clients.Clients'], init: function() { this.control({

我有一个关于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 grid = button.up("grid");

我真的不知道在哪里声明变量…

在OnButtonClickRefresh侦听器中,您可以得到如下网格:

OnButtonClickRefresh: function (button, e, options) {
         Grid.getStore (). Load ();
     }
var grid = button.up("grid");

链接到

如果您查看

您可以在控制器中设置
refs
,并使用生成的getter获取所需的网格。例如,如果您有值为
clientsGrid
ref
,那么getter
getClientsGrid()
将由ExtJS创建

`


`

在控制器中,您需要使用。例如:

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
    }
});

伟大的它是有效的,感谢您向我展示了“refs”的用法,在阅读了一些文档之后,我理解了它的用法。