PDA

View Full Version : Hook into keycode 23 (enter) on grid



samsmits
23 Oct 2006, 8:50 AM
Hi,

I've been trying to hook into the grid's keypress in order to listen for hitting enter on a selected row. It seems to be returning an object to me, however.

Anyone have any success with this? This is not in the context of a editable grid, but in the standard selection mode. Basically, I want to give the user the ability to scroll the grid with arrows (which is already native to the grid) and hit enter on a selected row to cause an action.

Thanks!

jack.slocum
23 Oct 2006, 2:03 PM
If you are using:


function handleKeyDown(e){...}
grid.on('keydown', handleKeyDown);


Then you will be receiving a raw event object (YAHOO.ext.EventObject).

As far as receiving a keydown event on a particular row, I'm not sure if this will work but it might (you will need a reference to yourGrid):


function handleKeyDown(e){
if(e.browserEvent.keyCode == e.RETURN){
var row = yourGrid.getRowFromChild(e.getTarget());
if(row){
// now you have your row
}
}
}