admin管理员组文章数量:1389768
This is probably something incredibly simple I'm missing, but I can't figure out why my listener won't work here.
I've defined a grid with a few colums below:
...
{header: 'Privacy', dataIndex: 'PRIVACY_INDICATOR', flex: 3, tdCls: 'grid_cell'},
{header: 'Lineage', dataIndex: 'popup', renderer: renderPopupIcon, flex: 1, tdCls: 'pop_cell', id: 'lineage_button',
listeners: {
cellclick: function(record) {
alert('cell has been clicked');
}
}
}
I have tried everything, but I can't seem to get the alert to fire.
Any ideas?
This is probably something incredibly simple I'm missing, but I can't figure out why my listener won't work here.
I've defined a grid with a few colums below:
...
{header: 'Privacy', dataIndex: 'PRIVACY_INDICATOR', flex: 3, tdCls: 'grid_cell'},
{header: 'Lineage', dataIndex: 'popup', renderer: renderPopupIcon, flex: 1, tdCls: 'pop_cell', id: 'lineage_button',
listeners: {
cellclick: function(record) {
alert('cell has been clicked');
}
}
}
I have tried everything, but I can't seem to get the alert to fire.
Any ideas?
Share Improve this question asked Oct 4, 2013 at 18:01 Clay BanksClay Banks 4,60115 gold badges78 silver badges150 bronze badges2 Answers
Reset to default 3Well cellclick
event is available to grid and not to column. You have added cellclick
listener on column where you should add it to grid. See below example, you can run it on column's Ext Doc Code Editor, simply copy and paste it and select Live Preview
:
Ext.create('Ext.data.Store', {
storeId:'employeeStore',
fields:['firstname', 'lastname', 'seniority', 'dep', 'hired'],
data:[
{firstname:"Michael", lastname:"Scott", seniority:7, dep:"Management", hired:"01/10/2004"},
{firstname:"Dwight", lastname:"Schrute", seniority:2, dep:"Sales", hired:"04/01/2004"},
{firstname:"Jim", lastname:"Halpert", seniority:3, dep:"Sales", hired:"02/22/2006"},
{firstname:"Kevin", lastname:"Malone", seniority:4, dep:"Accounting", hired:"06/10/2007"},
{firstname:"Angela", lastname:"Martin", seniority:5, dep:"Accounting", hired:"10/21/2008"}
]
});
Ext.create('Ext.grid.Panel', {
title: 'Column Demo',
store: Ext.data.StoreManager.lookup('employeeStore'),
columns: [
{text: 'First Name', dataIndex:'firstname'},
{text: 'Last Name', dataIndex:'lastname'},
{text: 'Hired Month', dataIndex:'hired', xtype:'datecolumn', format:'M'},
{text: 'Department (Yrs)', xtype:'templatecolumn', tpl:'{dep} ({seniority})'}
],
listeners: {
cellclick: function(view, td, cellIndex, record, tr, rowIndex, e, eOpts) {
Ext.Msg.alert('Selected Record', 'Name : ' + record.get('firstname') + ' ' + record.get('lastname'));
}
},
width: 400,
forceFit: true,
renderTo: Ext.getBody()
});
UPDATE :
If you want to capture event only for particular cell/column, you can use cellIndex
property which is one of among cellclick
function's argument. For e.g. : you want to show alert when user clicks on Lineage
column and that column is 4th column, you will use below code :
cellclick: function(view, td, cellIndex, record, tr, rowIndex, e, eOpts) {
// if clicked on cell 4, show popup otherwise ignore
if(cellIndex == 3) { // cellIndex starts from 0
Ext.Msg.alert('Selected Record', 'Name : ' + record.get('firstname') + ' ' + record.get('lastname'));
}
}
Which version of ExtJS are you using? It is noticed that in certain versions (4.1.1 for sure) cellclick
event is not being fired at all (see the ments in the offical documentation). If that's that case, try with itemclick
event. Another reason could be that you are catching this event with
cellclick: function(record) {..
and you should with
cellclick: function(field, td, cellIndex, record, tr, rowIndex, e, eOpts) {..
本文标签: javascriptListener not working on Grid PanelExt JSStack Overflow
版权声明:本文标题:javascript - Listener not working on Grid Panel - Ext JS - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1744677508a2619201.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论