1

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:

  • Row should not be selected or deselected (if previously selected) on right click in a jqGrid.

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

JGV
  • 5,037
  • 9
  • 50
  • 94

1 Answers1

3

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.

Community
  • 1
  • 1
xCRKx TyPHooN
  • 808
  • 5
  • 18
  • I looked at that post, but as I said, I need to preserve the previous selection. Basically, right click should not select or deselect a row. – JGV Apr 26 '16 at 20:19
  • Oh I missed that line. I'll keep looking! – xCRKx TyPHooN Apr 26 '16 at 20:19
  • 1
    `jQuery("#sg1").unbind("contextmenu");` visually works but disables the onRightClickRow event entirely. Do you need it to work while still capturing the click event? – xCRKx TyPHooN Apr 26 '16 at 20:27
  • I am not using any context menu in my grid. Let me try that. – JGV Apr 26 '16 at 20:44
  • Please update your answer with the last suggestion. It helped in disabling the row selection on right click. Fiddler of my attempt: https://jsfiddle.net/99x50s2s/239/. Thank you :) – JGV Apr 26 '16 at 20:48