Irving
Irving

Reputation: 1267

Disable row select in jqGrid on right click

In jqGrid, I am currently disabling row select with the following:

beforeSelectRow: function() {
     return false;
}

This works fine for left clicking. However, I noticed it's not firing the beforeSelectRow event handler and still selecting the row when I right click. This is a problem for me since I'm implementing a custom context menu.

I am able to get around this with what asker himself admitted is a hack found here: Is it possible to Stop jqGrid row(s) from being selected and/or highlighted?

Is there any other, less hacky way to do this?

Thanks!

Update

It appears this is only a problem with subgrids. Please refer to this example. You'll notice left clicking does not select the row but right clicking does.

(I took the lazy way out and stole this example from an answer to a different question provided by Oleg.)

Upvotes: 2

Views: 9335

Answers (1)

zs2020
zs2020

Reputation: 54524

If you want to disable the row select, you can config onSelectRow to return false, this will block both left click and right click.

onSelectRow: function() {
     return false;
}

To force unselect row on right click:

onRightClickRow: function () {
    grid.jqGrid('resetSelection');
    return false;
}

Upvotes: 9

Related Questions