PDA

View Full Version : How to get cell index (or dataIndex) of the cell that triggered itemcontextmenu ?



ttbgwt
29 Aug 2012, 5:54 AM
How can I get the cell index (or dataIndex) of the cell that triggered this itemcontextmenu of a grid view?



listeners: {
itemcontextmenu: function (view, record, el, index, e, eOpts) {
e.preventDefault();
//how can I get the cell index (or dataIndex) of the cell that triggered this itemcontextmenu?
}
}

scottmartin
29 Aug 2012, 8:24 AM
Have a look at:



var pos = grid.getSelectionModel().getCurrentPosition();
console.log(pos);


Scott.

ttbgwt
30 Aug 2012, 1:28 PM
I landed up listening to the cellcontextmenu event on the grid's view...



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


e.preventDefault();


var column = view.getHeaderByCell(cell);
var position = view.getPositionByEvent(e);
var columnIndex = position.column;
var dataIndex = column.dataIndex;