Mike Carey
Mike Carey

Reputation: 131

How can I add to a Dojo Grid Event instead of replacing it?

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?

Upvotes: 0

Views: 2440

Answers (1)

seth
seth

Reputation: 37297

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.

Upvotes: 2

Related Questions