SE_User
SE_User

Reputation: 370

Creating a new row when enter key is pressed in KendoUI Grid while editing

I tried using various code snippets for implementing this particular functionality of creating a new row when you press enter key WHILE YOU ARE EDITING in a particular cell.

`$(document).on('keypress','body',function(event){
    var keycode = (event.keyCode ? event.keyCode : event.which);
  if(keycode == '13'){
    grid.addRow();

  } 
});​

The above code worked when you simply press enter key, but when you're editing a cell and pressing enter key, it did not create a new row.

I want to create a new row when you press enter key while editing a particular cell.

It would be really great if someone can help me regarding this.

Thanks in advance. Here's the js fiddle.

In short:- If i am editing in a particular cell, when i press the enter key, it should create a new row!

https://jsfiddle.net/aravind_93/c1f3t6yo/

Upvotes: 3

Views: 1024

Answers (1)

SE_User
SE_User

Reputation: 370

It worked when I replaced "body" with "#stocks_tbl" and "keypress" with "keyup"!

$(document).on('keyup','#stocks_tbl',function(event){
var keycode = (event.keyCode ? event.keyCode : event.which);
if(keycode == '13'){

    var grid = $("#stocks_tbl").data("kendoGrid");
    grid.addRow();                        
} 
});

Link to updated JS FIDDLE

' #Kendo UI '

Upvotes: 3

Related Questions