PDA

View Full Version : DataIndex of grid in ExtJS 4.1



Pravin.Pawar
31 Aug 2012, 5:26 AM
Hi,

I have added following code to fire cell click event of the grid. I want to get data of the cell on which user clicked. In following code; 'Address' is the name of dataIndex (one column) of the grid.


listeners: {
cellclick: function (grid, td, cellIndex, record, tr, rowIndex, e, eOpts) {
var record = grid.getStore().getAt(rowIndex);
var data= record.get('Address');
}
},

Please let me know how should can I read dataindex value from the above events so that I can pass to
record.get(dataIndexName) instead of hardcoding.

Thanks, Pravin

scottmartin
31 Aug 2012, 6:59 AM
You can use the following:


var fieldName = grid.getColumnModel().getDataIndex(col);

Scott.

vietits
31 Aug 2012, 6:41 PM
var dataIndex = grid.headerCt.getGridColumns()[colIndex].dataIndex;

Pravin.Pawar
1 Sep 2012, 6:12 AM
Thanks, we can get values with following code-

grid.on('cellclick', function (grid, td, cellIndex, record, tr, rowIndex, e, eOpts) {
var record = grid.getStore().getAt(rowIndex);
var dataIndex = grid.headerCt.getGridColumns()[cellIndex].dataIndex;
var coltext = grid.headerCt.getGridColumns()[cellIndex].text;
}