JGV
JGV

Reputation: 5187

jqGrid - suppress row selection on right click

In jqGrid, I want to disable row selection on right click. But, want to have the normal behavior (row selection on left click) enabled.

I tried to disable row selection on right click using the following code, but it does not have any effect,

onRightClickRow: function (rowid, iRow, iCol, e) {
   return false;
}

Fiddler: https://jsfiddle.net/99x50s2s/235/

Expectation:

I am using jqGrid 4.6.0. Any suggestion will be appreciated.

Upvotes: 1

Views: 1112

Answers (1)

xCRKx TyPHooN
xCRKx TyPHooN

Reputation: 808

You can do what this post suggests: Disable row select in jqGrid on right click

https://jsfiddle.net/99x50s2s/236/

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

It works, but just from playing around with it I noticed it unselects the previously selected row, which might not be ideal. If that's not a problem than this should be sufficient!

EDIT

If you want to maintain the previously selected row, you'll have to do something a little different.

https://jsfiddle.net/99x50s2s/239/

jQuery("sg1").unbind("contextmenu");

or

jQuery("#sg1").jqGrid({
    //Parameters
}).unbind("contextmenu");

This works, but disables the onRightClickRow event entirely.

Upvotes: 3

Related Questions