View Full Version : Stop rowselect event when clicking on a link within grid cell

14 Mar 2011, 12:13 PM
While I have found a ton of posts in the forums on this issue, I can't figure out how any one solved it. I have a gridpanel that does an action when somebody selects a row, works just fine. The row content is html and may have one or more links included. So I have a LinkInterceptor that makes those href's open in a new window, works just fine...

But, I need to figure out how to prevent the "rowselect" event from happening when just the link is clicked. The rowselect event does not include a reference to the 'event', so I can't stop it. The same situation for the beforerowselect event.

Looking at the rowExpander plugin as an example, it appears I need to intercept the mousedown event on the grid, so I do this:

/* gp is my gridPanel */
gp.on('render', function(){
this.getView().mainBody.on('mousedown', function(e,t){
if (t.tagName == 'A'){
t.target = '_blank';
}, gp);

This appears to work, is this the proper thing to do? thanks!

14 Mar 2011, 12:29 PM
Take a look at cellclick, probably more what you're looking for. I use cellclick when I use links inside grids.

14 Mar 2011, 12:33 PM
Thank you! Would you mind sharing a code snippet of what you do?

14 Mar 2011, 12:36 PM
listeners: {
cellclick: function( g, r, c, e ) {
if( c == 7 ) {
var _d = _store.getAt( r );
launchWin( _d.id );

r would be the record you're currently on
c would be the current column

14 Mar 2011, 12:39 PM
Thank you, but how does your code stop the rowselect event? How does your code know if you clicked on the link?

14 Mar 2011, 12:43 PM
My code voids an actual link and instead on click of the column it launches the function the link would be calling.

If you want to kill the rowselect you would likely just return false; on when you click on that cell

9 Sep 2013, 8:15 AM
This was a very helpful post. I was trying to use e.stopEvent() in the cellclick event and it didn't work. So I used
return false to store the rowselect event from firing.