Indicating ctrl + click on row

2 posts, 0 answers
  1. Marcin
    Marcin avatar
    3 posts
    Member since:
    Feb 2017

    Posted 17 Jul Link to this post

    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?

  2. Preslav
    Admin
    Preslav avatar
    445 posts

    Posted 17 Jul Link to this post

    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.
Back to Top