what's the best way to get the form to submit on enter. Cancel works with Esc key.
1 Answer, 1 is accepted
0
Martin Bechev
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:
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.