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

get middle mouse click on Custom command button

1 Answer 15 Views
Grid
This is a migrated thread and some comments may be shown as answers.
marcus
Top achievements
Rank 2
marcus asked on 18 Sep 2019, 06:35 AM

Hello,

is there a way to overwrite the browsers (chrome and firefox) default behavior for middle or right click on custom buttons in a grid?

We are trying to get the middle mouse click on a custom command button in a grid.

With this line we only get the left mouse click, the middle and right are ignored/use the default browser commands 

command.Custom("Details").Text(" ").Click("showDetails").IconClass("fas fa-eye");

Middle - new tab

Right - context menu

We tryed using JS on the mousedown event but it didn't work and in the "showDetails" method we only get the left mouse button

$('.k-grid-Details').on('mousedown', function (e) {
    debugger
     if (e.which == 1) {
       e.preventDefault();
       alert("middle button");
});

 

 

1 Answer, 1 is accepted

Sort by
0
Eyup
Telerik team
answered on 20 Sep 2019, 05:36 PM

Hello Marcus,

 

This is rather a default browser behavior and not related specifically to Telerik. You can observe the same behavior with a standard <a> element on the page:

https://superuser.com/questions/680175/is-it-possible-to-prevenet-javascript-from-detecting-middle-mouse-click

 

However, it is still possible to achieve what you are after using the following configuration:

columns.Command(command => command.Custom("Details")
         .Text("Hello").Click("showDetails").IconClass("fas fa-eye")
         .HtmlAttributes(new { href = "javascript: void(0);",
         oncontextmenu = "return false;" } ));

 

I hope this will prove helpful. Feel free to give it a try and let me know about the result.

 

Regards,
Eyup
Progress Telerik

Get quickly onboarded and successful with your Telerik and/or Kendo UI products with the Virtual Classroom free technical training, available to all active customers. Learn More.
Tags
Grid
Asked by
marcus
Top achievements
Rank 2
Answers by
Eyup
Telerik team
Share this question
or