PDA

View Full Version : How to get grid click column name on extjs4?



telo.tao.yang
30 Jul 2012, 2:10 AM
How can i get the click column name on extjs4's grid.
in the 2.x, i can use grid.getColumnModel().getColumnId(columnIndex).
but in 4.x, getColumnModel() disappeared.

sword-it
30 Jul 2012, 3:47 AM
Hi,

you can try following code




yourgrid.getSelectionModel().addListener('select', function (selModel, record, row, column, eOpts) {
alert(yourgrid.columns[column].text);
});

telo.tao.yang
30 Jul 2012, 8:29 AM
will get error of : grid.columns is undefined
my code like this:
controller:
'quotationQuotationPanel > gridpanel':{celldblclick: this.gridDbClick},
......

gridDbClick: function(grid, td, cellIndex, record, tr, rowIndex, e, oPts){
alert(grid.columns[cellIndex].text); //get error: grid.columns is undefined
return;
}

sword-it
30 Jul 2012, 10:36 PM
Hi,

try to use this:




alert(grid.ownerCt.columns[cellIndex].text)



in your code you are getting the view of the gridpanel instead of gridpanel