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

Kendo Keyboard Shortcut for "Update" button

8 Answers 246 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Cody
Top achievements
Rank 1
Cody asked on 26 Sep 2018, 01:44 PM
Hi, not sure if anyone would know this, but when I hit "Add new Record" and I fill out the new record I'd like to hit CTRL+ENTER and it "insert" that record. Anyone have any idea how to do this? I looked on google but couldn't quite figure it out.

8 Answers, 1 is accepted

Sort by
0
Accepted
Stefan
Telerik team
answered on 28 Sep 2018, 07:09 AM
Hello, Cody,

This can be achieved by attacking using keydown handler on the Grid and programmatically clicking the update button when this combination of keys is preset. The handler can be attached to the onDataBound event:


dataBound:function(event){
  $('.k-grid').keydown(function(e){
    if(e.ctrlKey === true && e.keyCode === 13){
      $('.k-grid').find('.k-grid-update').click()
    }
  })
},

I made an example in jQuery, but the implementation using Grid for ASP.NET Core is the same:
 
https://dojo.telerik.com/ujUnUfaW

I hope this is helpful.

Regards,
Stefan
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.
0
Cody
Top achievements
Rank 1
answered on 28 Sep 2018, 12:08 PM
Great I'll give it a try shortly
0
Cody
Top achievements
Rank 1
answered on 28 Sep 2018, 12:43 PM
Worked like a charm :)
0
Cody
Top achievements
Rank 1
answered on 28 Sep 2018, 12:44 PM
Worked like a charm :)
0
Cody
Top achievements
Rank 1
answered on 28 Sep 2018, 07:48 PM

after further testing it enters 1 row. then when i do it again it enters 2 rows. then when i do it again it enters 3 rows, making it a total of 6 rows instead of 3. I have a Master Table then a detailed table so I made it:

dataBound:function(event){

$('.k-detail-cell').keydown(function (e) {
                                if (e.ctrlKey === true && e.keyCode === 13) {
                                    $('.k-detail-cell').find('.k-grid-update').click()
                                }
                            })

}

 

any thoughts

0
Stefan
Telerik team
answered on 01 Oct 2018, 06:46 AM
Hello, Cody,

As the detail Grid has multiple details rows, this handler is probably attached multiple time.

I can suggest attacking this to the details Grid dataBound event and instead of using the class selector the use the event that contains only the current Grid:

dataBound:function(event){
  $(event.sender.wrapper).keydown(function(e){
    if(e.ctrlKey === true && e.keyCode === 13){
      $('.k-grid').find('.k-grid-update').click()
    }
  })
},

The other option will be to remove the event handler every time before attaching it, to ensure that if there are other handlers they will be removed:

dataBound:function(event){
  $(event.sender.wrapper).unbind("keydown")
  $(event.sender.wrapper).keydown(function(e){
    if(e.ctrlKey === true && e.keyCode === 13){
      $('.k-grid').find('.k-grid-update').click()
    }
  })
},

Please check the first approach initially, as the second is removing the keydown handler and this could affect some functionalities if they depend on it.

Regards,
Stefan
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.
0
Cody
Top achievements
Rank 1
answered on 01 Oct 2018, 01:15 PM
I’ll give it a try tonight :)
0
Cody
Top achievements
Rank 1
answered on 13 Mar 2019, 01:28 PM
I just wanted to say I got this to work. I just removed the need to push "ctrl" and it worked fine :) Now I just hit ENTER and it inserts the line for me!
Tags
Grid
Asked by
Cody
Top achievements
Rank 1
Answers by
Stefan
Telerik team
Cody
Top achievements
Rank 1
Share this question
or