PDA

View Full Version : Grid context menu - select the row that was rightclicked



karga
20 Sep 2009, 10:50 AM
Hi,

Is it possible to select the row that was right clicked in a grid? I'm trying to add a context menu, but when the row isn't marked upon right click the functionality disappears

mjlecomte
20 Sep 2009, 3:57 PM
For inspiration...




this.on('rowcontextmenu', this.onRowContextMenu, this);


// this function handles row selection and context menu
onRowContextMenu : function(grid, rowIndex, e) {

e.stopEvent();//prevents default behavior from proceeding
var selModel = this.getSelectionModel();
if (selModel instanceof Ext.grid.RowSelectionModel) {// if the menu has been set
//In case no rows are selected, select the row and fire the click event
if (!selModel.isSelected(rowIndex)) {
selModel.selectRow(rowIndex);
this.fireEvent('rowclick', this, rowIndex, e);
}
// call the showContextMenu function for further processing
this.showContextMenu(e, rowIndex);
}
},

karga
20 Sep 2009, 10:00 PM
Ah of course! I knew it was something easy, cos i've done it before.. I used context instead of rowcontext.. Contextmenu hasn't got any parameters except the event object

Thanks :) i'll give it a go when I get home

oturkan
1 May 2012, 12:47 PM
Hi,
Ext.grid.RowSelectionModel is not working for ext 4.1. is there any fix