I have a dojo grid on which I want to perform some action when the "ENTER" key is pressed. However, I only want to add to what DOJO already does when a key is pressed. When I try to use a handler it replaces the onKeyDown function in dojox.grid._Events instead of adding to it. Is there any way I can make sure that the _Events function is called before my additions in my handler function?
A:
You can connect to the onKeyPress function on the grid object. For example:
var grid = dijit.byId('myGrid');
dojo.connect( grid, "onKeyPress", function(evt) {
if(evt.keyCode === dojo.keys.ENTER) {
console.log('ENTER!');
}
});
The dojox.grid._Grid
class (which is a parent class for all grids) is extended from dojox.grid._Events
so all of those methods are available for connecting.
seth
2009-08-17 20:36:01
I added this in the addOnLoad function and got nothing. dojo.addOnLoad(function() { <your code here> }); Tried both onKeyPress and onKeyDown, tried both console.log and alert. I'm using dojo 1.3 in IE 1.6.
Mike Carey
2009-08-19 21:21:46
IE 1.6? do you mean IE6
seth
2009-08-19 21:22:53
Is your grid in a div with id = 'myGrid'? Is the grid object undefined?
seth
2009-08-19 21:23:36