View Full Version : How to remove the click event handler from a Grid?

18 Jun 2007, 8:44 AM

How can I remove the click event handler from a Grid?
In order to use: removeListener(String eventName, Function handler); I need to know the handler's name.


18 Jun 2007, 9:03 AM
You want to just disable the default click handling? You could override the onClick funcion with an empty function

18 Jun 2007, 10:29 AM
How can I override this function? Do you mean I should change the ext-all.js file?

I tried using: grid.removeListener('click',onClick); - but I have an error. Can I use the removeListener function for this purpose?


18 Jun 2007, 10:54 AM
To override a function use this syntax:

Ext.override(ClassName, {
functionName : function(params){
//contents of the new function

so in your case it would be

Ext.override(Ext.grid.Grid, {
onClick: function(e){

Actually changing the library code is not advisable because it would make it much more difficult to upgrade to a newer version in the future. Overriding can have the same problems, but at least the code is separated enough that it shouldn't take too long to revise with an update.

18 Jun 2007, 11:14 AM
Thanks for your reply, para.

Do you know what are the EditorGrid functions that are executed when clicking on a Grid's cell?

I am trying to prevent the EditorGrid from moving the cursor out of focus each time I click on a cell's content.

When I purge all listeners, it works.
But when I override the "onClick" function - it doesn't work.

Any suggestions?


18 Jun 2007, 11:15 AM
To simpel override the grid click event:

// if the grid is referenced by the variable grid
grid.getSelectionModel().on('beforerowselect', function(e, rownumber){
return false;

18 Jun 2007, 11:18 AM
you can find all the events for EditorGrid in firebug and then use the "on" method to disabled the event or do whatever you want. You can also see which events the EditorGrid has in the documentation: http://extjs.com/deploy/ext/docs/output/Ext.grid.EditorGrid.html#events

18 Jun 2007, 11:37 AM
You would have to look in the code to determine which functions are being called. They are being called at the Grid and the EditorGrid levels.
What exactly do you mean by cursor out of focus?

18 Jun 2007, 11:54 AM
Thanks - it works.

Using the method dotnetCarpenter suggested, I don't need to know the handling function names - just the event names. I used it and it works just fine.

para - regrading your question, when I have an editable element inside the Grid and I click on it - I want the cursor to stay inside the element.

Thanks again for both of you,

18 Jun 2007, 2:31 PM
I wonder if the following code would work (not tested but similar problem I had with the tree)? By the way finding function names etc. is easy just look through in the source directory, in this case source/widgets/grid/ and I think RowSelectionModel.js - for the click / mousedown event.

grid.un('mousedown', grid.handleMouseDown, grid);