Keystroke to Add new record or Save Changes in grid

1 Answer 154 Views
Grid
Yvette
Top achievements
Rank 1
Yvette asked on 10 Aug 2022, 07:12 PM

hi, I have a simple grid set up for data entry in batch mode. The users don't like having to take their fingers off the keyboard and use the mouse to click a button to either start a new entry or save the changes in the current row. Hitting the Enter key doesn't do anything. Is there a keystroke available that would save the changes in the current row without having to click the Save button?

Similarly, is there a keystroke that would start a new record entry?

If not, any ideas for implementing something like this?

many thanks,

Yvette

 

1 Answer, 1 is accepted

Sort by
0
Momchil
Telerik team
answered on 15 Aug 2022, 04:00 PM

Hi Yvette,

To implement the behavior you described, you could use the following approach.

1. Use jQuery to handle the event when the Ctrl + Enter key combination is entered, and invoke the Grid addRow() method. 

$(document).on('keyup', function (e) {
            if (e.ctrlKey == true && e.keyCode == '13') { // 13 is the ASCII code of the Enter key
                var grid = $("#Grid").data("kendoGrid");
                grid.addRow();
            }
});

2. Handle the event when the Shift + Enter key combination is entered, and invoke the Grid saveChanges() method. 

 $(document).on('keyup', function (e) {
            if (e.shiftKey == true && e.keyCode == '13') { 
                var grid = $("#Grid").data("kendoGrid");
                grid.saveChanges();
            }
});

Here is a runnable REPL demo that illustrates this approach.

The key combinations I used are just for demonstration purposes, you can customize them to your preference.

I hope you find this example useful. Let me know if what I suggested works as per your expectations.

 

Best Regards,
Momchil
Progress Telerik

Love the Telerik and Kendo UI products and believe more people should try them? Invite a fellow developer to become a Progress customer and each of you can get a $50 Amazon gift voucher.

Tags
Grid
Asked by
Yvette
Top achievements
Rank 1
Answers by
Momchil
Telerik team
Share this question
or