Set focus on custom field in advanced scheduler form

3 posts, 0 answers
  1. rugydp
    rugydp avatar
    20 posts
    Member since:
    Jul 2014

    Posted 13 Jul 2016 Link to this post

    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.        {         
    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. Veselin Tsvetanov
    Veselin Tsvetanov avatar
    1083 posts

    Posted 18 Jul 2016 Link to this post

    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');
        }, 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.

    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.
  3. rugydp
    rugydp avatar
    20 posts
    Member since:
    Jul 2014

    Posted 20 Jul 2016 in reply to Veselin Tsvetanov Link to this post

    Thank you, Veselin
Back to Top