How to customize interaction
You can customize mouse and keyboard events in Grid by passing in your own mouse and keyboard handlers. By passing in custom handlers, you can determine the behavior of mouse and keyboard events.
In this example below, we display an alert whenever a cell is double-clicked or whenever a key is pressed.
In addition to adding your own custom behaviour, it's possible to override existing behaviour. When a mouse or keyboard event occurs, Grid will iterate through all registered handlers, sorted by their specified order
. If a handler returns true
, Grid will stop iterating and not call any other handlers. If no handler returns true
, Grid will continue to the next handler in the list.
For example, if you want to prevent the default behaviour of selecting a cell when it is clicked, you can return true
in the onClick
method of your custom mouse handler.
You can see the default registered mouse handlers and their registered priority orders in Grid initialization code.