This is a migrated thread and some comments may be shown as answers.

Right-click and row selection

2 Answers 430 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Brian Roth
Top achievements
Rank 1
Brian Roth asked on 24 Jan 2013, 10:14 PM
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 Answers, 1 is accepted

Sort by
0
Accepted
Vladimir Iliev
Telerik team
answered on 25 Jan 2013, 10:17 AM
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!
0
Brian Roth
Top achievements
Rank 1
answered on 25 Jan 2013, 03:37 PM
Worked like a charm.  Thanks!  Also, thanks for adding this as built-in functionality for future releases.  You guys are the best!

Regards,
Brian
Tags
Grid
Asked by
Brian Roth
Top achievements
Rank 1
Answers by
Vladimir Iliev
Telerik team
Brian Roth
Top achievements
Rank 1
Share this question
or