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

Focus button in kendoDialog

3 Answers 261 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Tayger
Top achievements
Rank 1
Iron
Tayger asked on 27 Mar 2017, 09:59 AM

Hello

I'm not sure if I'm right here but I couldn't find a topic for kendoDialog...

I have a dialog mask in my application (KendoUI, Javascript/JQuery) with two buttons: "Ok" and "Cancel". I would like to set the focus to the "Ok" button by default or at least when the dialog window is opened. I tried different things like setting .focus() on the first found .k-button, I tried to simulate a TAB command (that sets the focus to the "OK" button doing this by keyboard) on kendoDialog event "open", but everything around that didn't work. I assume that .focus() doesn't work because its not an official HTML button.

Is there a (simple) way to set the focus in a kendoDialog to a button?

Regards

3 Answers, 1 is accepted

Sort by
0
Ivan Danchev
Telerik team
answered on 30 Mar 2017, 06:53 AM
Hello,

You can use the Kendo UI Confirm dialog, which is a predefined Dialog and by default it has its OK button focused. Here's a dojo example.

Regards,
Ivan Danchev
Telerik by Progress
Try our brand new, jQuery-free Angular 2 components built from ground-up which deliver the business app essential building blocks - a grid component, data visualization (charts) and form elements.
0
Dan
Top achievements
Rank 1
Iron
Veteran
answered on 28 Jan 2019, 07:26 AM

Hi,

Would be possible to set the focus to the Cancel button. I have a requirement for the OK button to be primary but the focus should be on Cancel. Can this be achieved using telerik?

0
Veselin Tsvetanov
Telerik team
answered on 29 Jan 2019, 03:59 PM
Hi Dan,

To achieve the desired you will need to implement the following handler for the Dilog show event:
show: function(e) {
    $('.k-dialog-buttongroup button:not(.k-primary)').focus();
}

Here you could find a small sample implementing the above.

Regards,
Veselin Tsvetanov
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.
Tags
General Discussions
Asked by
Tayger
Top achievements
Rank 1
Iron
Answers by
Ivan Danchev
Telerik team
Dan
Top achievements
Rank 1
Iron
Veteran
Veselin Tsvetanov
Telerik team
Share this question
or