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

Submit external form on key press Enter

1 Answer 2186 Views
Grid
This is a migrated thread and some comments may be shown as answers.
James
Top achievements
Rank 1
James asked on 04 Jun 2019, 04:50 PM

In you external form example:

https://www.telerik.com/kendo-angular-ui/components/grid/editing/external-editing/

what's the best way to get the form to submit on enter. Cancel works with Esc key.

1 Answer, 1 is accepted

Sort by
0
Martin
Telerik team
answered on 06 Jun 2019, 10:21 AM
Hi James,

Indeed, there is no built-in option to submit the form using Enter key. To achieve the desired behavior, we should use our custom JavaScript logic. The most straight-forward approach is to listen for Enter key presses.

Use the keydown event in the <kendo-dialog> component. In the event handler, check the pressed key and call the onSave() method when necessary:

template:
<kendo-dialog
         ...
        (keydown)="onKeyDown($event)"
        >
</kendo-dialog>
...
 
export class GridEditFormComponent {
 
  public onSave(e): void {
    ....
  }
 
  private onKeyDown(pressedKey) {
    if (pressedKey.key==="Enter") {
      this.onSave(pressedKey);
    }
  }
 
}

Check the following example which demonstrates External form which is submitted using the Enter key:

https://stackblitz.com/edit/angular-ird5wx?file=app/app.component.ts

I hope this helps. Let me know if I am missing something or any further assistance is required.

Regards,
Martin
Progress Telerik
Get quickly onboarded and successful with your Telerik and Kendo UI products with the Virtual Classroom free technical training, available to all active customers. Learn More.
Tags
Grid
Asked by
James
Top achievements
Rank 1
Answers by
Martin
Telerik team
Share this question
or