How to select row in grid on right-click ?
January 6th, 2009
I have implemented an eventlistener for right-click in my grid. This displays a contextmenu. Works fine.
But, I would also like to be able to select the row on which I right-clicked.
Does anyone have any information/tips/solution to this ?
Thanks !
regards,
Petter Kjeilen
Thanks ! That did the trick :-)
Petter
Inside the onContextClick, I added this line near the end:
this.getSelectionModel().selectRow(index); // select row that was right-clicked on
Here's the full routine:
onContextClick : function(grid, index, e){
if(!this.menu){ // create context menu on first right click
this.menu = new Ext.menu.Menu({
id:'grid-ctx',
items: [{
text: 'View in new tab',
iconCls: 'new-tab',
scope:this,
handler: function(){
this.viewer.openTab(this.ctxRecord);
}
},{
iconCls: 'new-win',
text: 'Go to Post',
scope:this,
handler: function(){
window.open(this.ctxRecord.data.link);
}
},'-',{
iconCls: 'refresh-icon',
text:'Refresh',
scope:this,
handler: function(){
this.ctxRow = null;
this.store.reload();
}
}]
});
this.menu.on('hide', this.onContextHide, this);
}
e.stopEvent();
if(this.ctxRow){
Ext.fly(this.ctxRow).removeClass('x-node-ctx');
this.ctxRow = null;
}
this.ctxRow = this.view.getRow(index);
this.ctxRecord = this.store.getAt(index);
this.getSelectionModel().selectRow(index); // select row that was right-clicked on
Ext.fly(this.ctxRow).addClass('x-node-ctx');
this.menu.showAt(e.getXY());
},
HTH
#If you have any other info about this subject , Please add it free.# |
Posted in freedeadaim.com | edit
A little something about you, the author. Nothing lengthy, just an overview.