PDA

View Full Version : Listener for "click" event in Column



DiptimanBadajena
20 Mar 2014, 4:52 AM
Hi,
I'm using extJS 3.4.0 and I'm a beginner. I want to handle the "click" event on a particular column in the Grid.
I was not able to make use of the "listeners" in the Column.

My Code:
var reportColModel = new Ext.grid.ColumnModel({
defaults: {
sortable: true
},
columns: [
........
{id: 'qualifyFlag',
header: 'Qualify Supplier',
dataIndex: 'qualifyFlag',
width: 80,
editor: yesNoCombo,
listeners: { click : function (this,The,rowIndex,e){ alert ('Identified Click'); }},
renderer: Ext.util.Format.comboRenderer(yesNoCombo)
},
..........

Please guide me how to handle the "click" event in this case.
I do not want to use the "cellclick" event on the GridPanel as I will then have to identify the column by "columnIndex". In future if the column I'm referring moves to other position then I've to change the "columnIndex" value.

willigogs
20 Mar 2014, 2:53 PM
Use the cellclick event as you tried previously - but instead of using the cellindex (which might change), get the index based on a column ID.


So give your column an ID, then do the following:



{id: 'qualifyFlag', header: 'Qualify Supplier', dataIndex: 'qualifyFlag'}




cellclick: function(thisGrid, rowIndex, columnIndex, e) {
var columnid = thisGrid.getColumnModel().getColumnAt(columnIndex).id;
if(columnid == 'qualifyFlag') {
//Do Something
}
}