Right-click and row selection

3 posts, 1 answers
  1. Brian Roth
    Brian Roth avatar
    136 posts
    Member since:
    Oct 2005

    Posted 24 Jan 2013 Link to this post

    I've implemented a right-click context menu for some of the grids in our project.  One of these grids is set up to allow multiple row selection.  I was hoping that when the user right-clicks I could have some options for them which would operate on all currently selected rows.  But it seems that the right-click is interpreted as a "Select" click and proceeds to select the row that the user has clicked over, which causes all the other rows to be deselected.  Is there a way to treat a right-click differently and have it not affect which rows are selected?

    Thanks for your help!

    Brian
  2. Answer
    Vladimir Iliev
    Admin
    Vladimir Iliev avatar
    2172 posts

    Posted 25 Jan 2013 Link to this post

    Hi Brian,

     
    You can attach "mousedown" event to the grid body which checks if the currently clicked mouse button is the right button to prevent the event from bubbling up using jQuery stopPropagation method. Please check the example below:

    $(function () {
        //replace with your grid name
        $("#Grid tbody").bind("mousedown", function (e) {
            if (event.button == 2) {
                     //prevent the event from bubbling
                e.stopPropagation();
            }
        })
    })
     
    Edit: In next internal builds we will disable grid selection using the right mouse button and the above solution will not be needed.

    Kind Regards,
    Vladimir Iliev
    the Telerik team
    Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
  3. UI for ASP.NET MVC is VS 2017 Ready
  4. Brian Roth
    Brian Roth avatar
    136 posts
    Member since:
    Oct 2005

    Posted 25 Jan 2013 Link to this post

    Worked like a charm.  Thanks!  Also, thanks for adding this as built-in functionality for future releases.  You guys are the best!

    Regards,
    Brian
Back to Top