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

Indicating ctrl + click on row

1 Answer 410 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Marcin
Top achievements
Rank 1
Marcin asked on 17 Jul 2018, 01:52 PM

Hello,

I have a case when I want to have different behavior for clicking when user have clicked with control key pressed. Unfortunately I have no information on data which is passed to 'change' handler. Is there a way to obtain this information and have condition in logic depending if ctrl key is pressed or not?

1 Answer, 1 is accepted

Sort by
0
Preslav
Telerik team
answered on 17 Jul 2018, 03:57 PM
Hi Marcin,

To achieve the desired behavior, handle the click event with jQuery.
For example:

$("#grid").on("click", "tbody > tr", function(e){
  var row = $(e.target).closest("tr");
  var rowIndex = row[0].rowIndex;
  var ctrlKey = e.ctrlKey;
   
  if(e.ctrlKey){
    alert("Clicked Row with ID: " + rowIndex + " and the Ctrl key is pressed");
  }else{
    alert("Clicked Row with ID: " + rowIndex + " and the Ctrl key is NOT pressed");
  }
});

For a runnable example, check my test Dojo:
I hope this helps.


Regards,
Preslav
Progress Telerik
Try our brand new, jQuery-free Angular components built from ground-up which deliver the business app essential building blocks - a grid component, data visualization (charts) and form elements.
Tags
Grid
Asked by
Marcin
Top achievements
Rank 1
Answers by
Preslav
Telerik team
Share this question
or