gpt4 book ai didi

ExtJS网格: handling action column's click event in the controller

转载 作者:行者123 更新时间:2023-12-02 11:01:42 25 4
gpt4 key购买 nike

我有一个 View “EmployeeList”。里面有一个网格。我需要处理来自 Controller 的操作列的单击事件。这是 View :

Ext.define('ExtApp.view.Employees', {
extend: 'Ext.panel.Panel',
alias: 'widget.employees',
.
.
.
.
.
});

该 View 包含一个网格:

xtype: 'grid',
columns:[{
.
.
.
.
xtype: 'actioncolumn',
text: 'Delete',
width: 100,
items: [{
icon: 'images/deleteEmployee.jpg',
tooltip: 'Delete'
}]
}]

如何在 Controller 中处理操作列的单击事件?

这是 Controller 的代码:

Ext.define('ExtApp.controller.Employees', {
extend: 'Ext.app.Controller',
refs: [{
ref: 'employees',
selector: 'employees'
}],
init: function () {
//reference for the grid's actioncolumn needed here

}
});

最佳答案

如果您想使用 Controller 处理点击,则必须向操作列添加一个处理程序,如下所示:

xtype:'actioncolumn',
width:50,
items: [{
icon: 'extjs/examples/shared/icons/fam/cog_edit.png', // Use a URL in the icon config
tooltip: 'Edit',
handler: function(view, rowIndex, colIndex, item, e, record, row) {
this.fireEvent('itemClick', view, rowIndex, colIndex, item, e, record, row, 'edit');
}
}]

然后在 Controller 中为 itemClick 事件添加事件处理程序

init: function() {
this.control({
'actioncolumn': {
itemClick: this.onActionColumnItemClick
}
});
},
onActionColumnItemClick : function(view, rowIndex, colIndex, item, e, record, row, action) {
alert(action + " user " + record.get('firstname'));
}

你应该看到它工作了,在这里摆弄:https://fiddle.sencha.com/#fiddle/grb

关于ExtJS网格: handling action column's click event in the controller,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28066941/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com