我有网格
Ext.define('a.view.a', {
extend: 'Ext.grid.Panel',
alias: 'widget.list',
store: 'a.store.store',
multiSelect: false,
enableKeyEvents: true,
initComponent: function() {
var me = this;
var user = TR.user;
this.addEvents('edit');
this.columns = [{
dataIndex: 'Id',
width: 50,
align: 'center',
sortable: false
}];
this.actions = {
edit: Ext.create('Ext.Action', {
text: 'Изменить заявку',
icon: 'Content/Resources/images/editDoc.gif',
cls: 'selected-griditem-button',
handler: function() {
this.fireEvent('edit', this.getRequest());
},
scope: this
})
};
var contextMenu = Ext.create('Ext.menu.Menu', {
items: [
this.actions.edit
]
});
this.on({
itemcontextmenu: function(view, rec, node, index, e) {
this.getSelectionModel().select(index);
e.stopEvent();
contextMenu.showAt(e.getXY());
return false;
},
beforeitemdblclick: function(gr, rowIndex, e) {
this.fireEvent('edit', this.getRequest());
}
});
this.viewConfig = {
listeners: {
itemkeydown: function(v, r, item, index, e) {
if (e.getKey() == e.DELETE) {
e.stopEvent();
this.fireEvent('del', this.getRequest());
}
},
scope: this
}
};
this.callParent(arguments);
},
getRequest: function() {
var sm = this.getSelectionModel();
var rs = sm.getSelection();
if (rs.length) {
return rs[0];
}
return null;
}
});
在我的控制器中,当我点击网格中的项目时,我有执行的功能
onSelectionChange: function (sm, rs) {
alert('wtf');
}
问题是
1.当我第一次单击网格中的项目时,同一项目上的消息框第二次显示“wtf”-没有(这很好)
1.但当我执行multiSelect:true时,每次单击同一项时都会显示消息(这不好:()
如何使用multiSelect: true
执行第一个变量
1条答案
按热度按时间j7dteeu81#
使用“itemclick”事件而不是“selectionchange”事件。下面是一个独立的示例: