The Cube - Assimilating Technology

The Cube

Override Magrnto Grid Row click

For Humans only

Print E-mail

The magento grid has built in functionality to call an action when a grid row is clicked.

This is great, but at times, you may need to prevent that default event from fireing, as seen in my article 'Grid Column Renderer',
where I have icons rendering in the grid column, and each icon needs to fire their own event action.

If the standard grid row action fires, you end up with tow actions going to your controller.

The key to changing this behaviour is the 'openGridRow' javascript funcion, which normally looks like this:

function openGridRow(grid, event){
                    var element = Event.findElement(event, 'tr');
                    if(['a', 'input', 'select', 'option'].indexOf(Event.element(event).tagName.toLowerCase())!=-1) {

The function is lcoated in magento's grid.js

Looking at the standard functionality you can see that the event is cancelled if the clicked item is an element of types 'a', 'input', 'select' or 'option'

The only thing I needed to do to change this behaviour was to implement my own version of the function, and ad the 'img' element to the list of elements.

Nice and easy, but a bit hidden.


Share on facebook