Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/extjs/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 如何使用MVC控制器文件中的查询组件选择extjs网格操作列?_Javascript_Extjs_Controller_Extjs4_Handler - Fatal编程技术网

Javascript 如何使用MVC控制器文件中的查询组件选择extjs网格操作列?

Javascript 如何使用MVC控制器文件中的查询组件选择extjs网格操作列?,javascript,extjs,controller,extjs4,handler,Javascript,Extjs,Controller,Extjs4,Handler,从MVC演示项目指南开始,我添加了一个额外的actioncolumn,我想知道如何将它连接到控制器文件中 指南: 控制器初始化函数 init: function() { this.control({ 'volatilityedit actioncolumn img' : { <--- ?? click: this.reset } }); }, reset: function(grid, rowIndex, colI

从MVC演示项目指南开始,我添加了一个额外的actioncolumn,我想知道如何将它连接到控制器文件中

指南:

控制器初始化函数

init: function() {
    this.control({
        'volatilityedit actioncolumn img' : {   <--- ??
            click: this.reset
        }
    });
},
reset: function(grid, rowIndex, colIndex) {
    //var rec = grid.getStore().getAt(rowIndex);
    alert("Go");
},
init:function(){
这是我的控制({

'volatityedit actioncolumn img':{这是一个在控制器中包含操作列和函数的示例:
视图:

控制器:

'.grid_alias actioncolumn[id=actionColumnGrid]': {
click: me.onActionColumnGridCasSelect
}


取决于你的行动应该做什么,你可以决定是否需要控制器。 当您的操作与其他组件交互时,您应该使用控制器,否则您可以在组件(网格)中编写自己的方法

下面是带有actioncolumn的网格的简单示例:

Ext.onReady(function () {
    Ext.create('Ext.data.Store', {
        storeId: 'employeeStore',
        fields: ['firstname', 'lastname', 'seniority', 'dep', 'hired'],
        data: [{
            firstname: "Michael",
            lastname: "Scott"
        }, {
            firstname: "Dwight",
            lastname: "Schrute"
        }, {
            firstname: "Jim",
            lastname: "Halpert"
        }, {
            firstname: "Kevin",
            lastname: "Malone"
        }, {
            firstname: "Angela",
            lastname: "Martin"
        }]
    });

    Ext.create('Ext.grid.Panel', {
        title: 'Action Column Demo',
        store: Ext.data.StoreManager.lookup('employeeStore'),
        columns: [{
            text: 'First Name',
            dataIndex: 'firstname'
        }, {
            text: 'Last Name',
            dataIndex: 'lastname'
        }, {
            xtype: 'actioncolumn',
            width: 50,
            items: [{
                icon: 'app/resources/images/cog_edit.png',
                // Use a URL in the icon config
                tooltip: 'Edit',
                handler: function (grid, rowIndex, colIndex) {
                    var rec = grid.getStore().getAt(rowIndex);
                    alert("Edit " + rec.get('firstname'));
                }
            }, {
                icon: 'app/resources/images/delete.png',
                tooltip: 'Delete',
                handler: function (grid, rowIndex, colIndex) {
                    var rec = grid.getStore().getAt(rowIndex);
                    alert("Terminate " + rec.get('firstname'));
                }
            }]
        }],
        width: 250,
        renderTo: Ext.getBody()
    });
});
'.grid_alias actioncolumn[id=actionColumnGrid]': {
click: me.onActionColumnGridCasSelect
}
onActionColumnGridCasSelect: function(view, cell, rowIndex, colIndex, e) {
    var m = e.getTarget().className.match(/\bact-(\w+)\b/);
    if (m === null || m === undefined) {
        return;
    }
    var action = m[1];

    switch (action) {
        case 'edit':
            alert('edit');
            break;
        case 'delete':
            alert('delete');
            break;
    }
}
Ext.onReady(function () {
    Ext.create('Ext.data.Store', {
        storeId: 'employeeStore',
        fields: ['firstname', 'lastname', 'seniority', 'dep', 'hired'],
        data: [{
            firstname: "Michael",
            lastname: "Scott"
        }, {
            firstname: "Dwight",
            lastname: "Schrute"
        }, {
            firstname: "Jim",
            lastname: "Halpert"
        }, {
            firstname: "Kevin",
            lastname: "Malone"
        }, {
            firstname: "Angela",
            lastname: "Martin"
        }]
    });

    Ext.create('Ext.grid.Panel', {
        title: 'Action Column Demo',
        store: Ext.data.StoreManager.lookup('employeeStore'),
        columns: [{
            text: 'First Name',
            dataIndex: 'firstname'
        }, {
            text: 'Last Name',
            dataIndex: 'lastname'
        }, {
            xtype: 'actioncolumn',
            width: 50,
            items: [{
                icon: 'app/resources/images/cog_edit.png',
                // Use a URL in the icon config
                tooltip: 'Edit',
                handler: function (grid, rowIndex, colIndex) {
                    var rec = grid.getStore().getAt(rowIndex);
                    alert("Edit " + rec.get('firstname'));
                }
            }, {
                icon: 'app/resources/images/delete.png',
                tooltip: 'Delete',
                handler: function (grid, rowIndex, colIndex) {
                    var rec = grid.getStore().getAt(rowIndex);
                    alert("Terminate " + rec.get('firstname'));
                }
            }]
        }],
        width: 250,
        renderTo: Ext.getBody()
    });
});