Search code examples
eventsextjsdatagridcolumn

ExtJS 5.0 cellclick event returns incorrect column


I'm trying to use cellclick on a grid where based on a certain column clicked, I want to run some operations. But every time, it returns a wrong column i.e. if I click on column 0 (first col), it returns the next column.

cellclick: function(view, td, cellIndex, record, tr, rowIndex, e, eOpts ){
    console.info(view.getGridColumns()[cellIndex].dataIndex);
if(view.getGridColumns()[cellIndex].dataIndex === 'someCol'){
//do something
    }
}

Solution

  • The view.getGridColumns() only returns visible columns. Instead I changed it to, the following and this returns all the visible/hidden columns.

    Ext.getCmp('gridId').columns[cellIndex].dataIndex
    

    Thank you @Yellen for the hint.