Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8747387
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T12:20:53+00:00 2026-06-13T12:20:53+00:00

In jqGrid, Is there a built-in way to know what mouse button was clicked,

  • 0

In jqGrid, Is there a “built-in” way to know what mouse button was clicked, before row selection?

Currently we have jqGrid with some actions bind on “onSelectRow” event of jqGrid. The problem is that when user right click on that row, onSelectRow event raised to and action performed. What I need, is to ignore “onSelectRow” when user right click on a row.

EDIT: I know there exists onRightClickRow event, but it raised after onSelectRow and action already performed.

I found that I can know what button clicked by “type” of event object. When it’s click, the type is “click” when it’s right click, the type is “contextmenu”….Does exists the additional way, or I must check type to know what button is clicked?

Thanks

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-13T12:20:54+00:00Added an answer on June 13, 2026 at 12:20 pm

    It’s good question! The reason of such behavior is the following. jqGrid register an event handler for the event contextmenu on the whole grid <table> element with the following code (see here)

    .bind('contextmenu', function(e) {
        td = e.target;
        ptr = $(td,ts.rows).closest("tr.jqgrow");
        if($(ptr).length === 0 ){return;}
        if(!ts.p.multiselect) { $(ts).jqGrid("setSelection",ptr[0].id,true,e);  }
        ri = ptr[0].rowIndex;
        ci = $.jgrid.getCellIndex(td);
        $(ts).triggerHandler("jqGridRightClickRow", [$(ptr).attr("id"),ri,ci,e]);
        if ($.isFunction(this.p.onRightClickRow)) {
            ts.p.onRightClickRow.call(ts,$(ptr).attr("id"),ri,ci, e);
        }
    });
    

    How one can see from the code it calls setSelection method and calls onRightClickRow callback and trigger jqGridRightClickRow event. So if you don’t need the selection of rows and if you don’t use onRightClickRow and jqGridRightClickRow you can just unbind the event handler:

    $("#list").unbind("contextmenu");
    

    If you do want use onRightClickRow callback or if you don’t sure whether you need to use jqGridRightClickRow somewhere you can “subclass” the event handler. The implementation is depend a little from the version of jQuery which you use. Starting with jQuery 1.8 one should use a little another call to get the current events registered on the DOM element. The corresponding code could be about the following:

    //$grid.unbind('contextmenu');
    
    var getEvents = $._data($grid[0], "events"); // $grid.data("events") in jQuery ver<1.8
    if (getEvents && getEvents.contextmenu && getEvents.contextmenu.length === 1) {
        var orgContextmenu = getEvents.contextmenu[0].handler;
        $grid.unbind('contextmenu', orgContextmenu);
        $grid.bind('contextmenu', function(e) {
            var oldmultiselect = this.p.multiselect, result;
            this.p.multiselect = true; // set multiselect to prevent selection
            result = orgContextmenu.call(this, e);
            this.p.multiselect = oldmultiselect; // restore multiselect
            return result;
        });
    }
    

    The demo demonstrate the above code live.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Is there a way to know if a row inside the jqgrid is in
Is there a way in jqgrid to have an editable column that uses a
Is there any way to hide a column in a jqGrid table, but have
Is there any way to disable jqgrid local cache??? I have a page which
I'm using jQGrid and I'm wondering if there is a way to get the
I have a jqgrid whose html is displayed in the following way. I build
am getting there with jqgrid, although i am still unable to save row data
Is there any way to select multiple rows in a jqGrid tree structure? On
jqGrid edit and add forms render every field in separate row. If there are
as you can see in jqgrid. There are some parameter that will be send

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.