Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Get value of clicked cell on grid

Tags:

extjs

extjs4

I have been trying to get the value of clicked cell on grid.

cellDblClick: function(self, td, cellIndex, record, tr, rowIndex, e, eOpts)

I know I can get the record data, but I need the name of the column to get the value of the data.

record.data["name_of_column"]

What's the approach to get the value of clicked cell on grid? Is it possible to get the column name of clicked cell on grid?

Can anyone shed the light for me?

N.B. I'm using extjs 4.2.1

like image 265
Eldwin Eldwin Avatar asked Feb 05 '14 11:02

Eldwin Eldwin


1 Answers

You can use viewConfig of grid with cellclick listener as follows.

 viewConfig : {
    listeners : {
        cellclick : function(view, cell, cellIndex, record,row, rowIndex, e) {

              var clickedDataIndex = view.panel.headerCt.getHeaderAtIndex(cellIndex).dataIndex;
              var clickedColumnName = view.panel.headerCt.getHeaderAtIndex(cellIndex).text;
              var clickedCellValue = record.get(clickedDataIndex);
          }
     }
 }
like image 147
Dev Avatar answered Sep 29 '22 08:09

Dev