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

Set focus on custom field in advanced scheduler form

2 Answers 52 Views
Scheduler
This is a migrated thread and some comments may be shown as answers.
rugydp
Top achievements
Rank 1
rugydp asked on 13 Jul 2016, 03:25 PM

I have a custom AdvancedScheduler Form in which I want to set the focus to a field programmatically in code behind.

So far I tried this, but although the code is called correctly, the .Focus() doesn't reflect in the form. What am I doing wrong?

01.protected void RadSchedulerPlanning_FormCreated(object sender, SchedulerFormCreatedEventArgs e)
02.        {         
03. 
04.            if ( (e.Container.Mode == SchedulerFormMode.AdvancedEdit) || (e.Container.Mode == SchedulerFormMode.AdvancedInsert))
05.            {
06.                var aukunr = (RadComboBox) e.Container.Controls[1].FindControl(id: "AUkunr");
07.                var textbausteinid = (RadDropDownList) e.Container.Controls[1].FindControl(id: "Textbaustein_Id");
08.                if (aukunr.Enabled)
09.                    aukunr.Focus();
10.                else
11.                    textbausteinid.Focus();
12.            }
13.        }

2 Answers, 1 is accepted

Sort by
0
Veselin Tsvetanov
Telerik team
answered on 18 Jul 2016, 11:19 AM
Hello Ruggero,

The reason for the observed issue is the fact that when the form is being loaded on client the focus is again returned to its subject field. What you could do in this case is to implement an event handler for the OnClientFormCreated client side event:
function onClientFormCreated(sender, args) {
    setTimeout(function () {
     // Find the input element of the drop-down list you need to focus
        var box = $telerik.$('#RadScheduler1_Form_ctl37_Input');
        box.focus();
        debugger;
    }, 300);
}

Note that you will have to timeout the execution of the focus function to execute it after the default focus has already been transferred to the Subject input field.

Regards,
Veselin Tsvetanov
Telerik by Progress
Do you need help with upgrading your ASP.NET AJAX, WPF or WinForms projects? Check the Telerik API Analyzer and share your thoughts.
0
rugydp
Top achievements
Rank 1
answered on 20 Jul 2016, 06:53 AM
Thank you, Veselin
Tags
Scheduler
Asked by
rugydp
Top achievements
Rank 1
Answers by
Veselin Tsvetanov
Telerik team
rugydp
Top achievements
Rank 1
Share this question
or