Set focus to the same radcombobox in Radgrid inline edit form

5 posts, 1 answers
  1. Vasssek
    Vasssek avatar
    190 posts
    Member since:
    Aug 2010

    Posted 28 Feb 2011 Link to this post

    Hello Telerik Team,

    I know that this kind of topic has been solved many times, but I couldn't have found solution in my case.

    I use inline editing form in the radgrid. I have radcombobox control defined inside of the radgrid <EditItemTemplate> section. The combobox has set property EnableLoadOnDemand=true.

    What I need to achieve is to set focus on the same combobox when requested item is selected. Now, when user selects some item from the combobox list it's updated properly, but focus in not set on it. I found something similar in this thread: http://www.telerik.com/community/forums/aspnet-ajax/combobox/set-focus-and-cursor-at-the-end-of-text-in-radcombobox.aspx

    I use this script in the protected void cmb_Artikel_SelectedIndexChanged(object sender, RadComboBoxSelectedIndexChangedEventArgs e):
    StringBuilder script = new StringBuilder();
    script.Append("Sys.Application.add_load(function(){");
    script.Append("var combo2 = $find('" + combo.ClientID + "');");
    script.Append("combo2.get_inputDomElement().focus();");
    script.Append("combo2.selectText(combo2.get_text().length, combo2.get_text().length); });");            
      
    RadScriptManager.RegisterStartupScript(Page, Page.GetType(), "comboCursor", script.ToString(), true);

    The script runs properly, the combobox gets focus after user selects some item. For this steps everything looks good and correct, the problem will appear when user clicks on update button in the edited row.

    Then the error message is appeared: Microsoft JScript runtime error: 'null' is null or not an object

    Detailed info about this error is in the attachment.

    I think that it will be related to Sys.Application.add_load from the above script section. Maybe there must be append some script for unload section when ajax request is completed ?

    Please help me to solve this issues.

    Best regards

    Vasssek
  2. Helen
    Admin
    Helen avatar
    1052 posts

    Posted 02 Mar 2011 Link to this post

    Hi Vasssek,

    We tried to reproduce the problem locally, but without much success. Please find attached our test files. Could you please modify our test project, so we can see the problem locally?

    Kind regards,
    Helen
    the Telerik team
    Registration for Q1 2011 What’s New Webinar Week is now open. Mark your calendar for the week starting March 21st and book your seat for a walk through all the exciting stuff we ship with the new release!
  3. Vasssek
    Vasssek avatar
    190 posts
    Member since:
    Aug 2010

    Posted 02 Mar 2011 Link to this post

    Hello Helen,

    I've changed a bit your example page. Now, when you choose item from combbox and then clik on update button, the error I described above is appeared...

    The customized web site is uploaded here http://www.uschovna.cz/download/AWE89ABKJGJ7EL7I/JIURHJRS57

    Note: I'm using .Net 3.5 framework and telerik dll version is 2010.3.1422.35...

    Best regards

    Vasssek
  4. Answer
    Helen
    Admin
    Helen avatar
    1052 posts

    Posted 08 Mar 2011 Link to this post

    Hello Vasssek,

    Please modify your code as the following:

    Copy Code
    Copy Code
    Copy Code
    protected void lstRegion_SelectedIndexChanged(object o, RadComboBoxSelectedIndexChangedEventArgs e)
       {
           RadComboBox combo = (RadComboBox)o;
           string script = "var combo2 = $find('" + combo.ClientID + "');combo2.get_inputDomElement().focus();combo2.selectText(combo2.get_text().length, combo2.get_text().length);";
           RadAjaxManager1.ResponseScripts.Add(script);
       }

    Also find attached the updated project. Hope it helps.

    Kind regards,
    Helen
    the Telerik team
    Registration for Q1 2011 What’s New Webinar Week is now open. Mark your calendar for the week starting March 21st and book your seat for a walk through all the exciting stuff we ship with the new release!
  5. Vasssek
    Vasssek avatar
    190 posts
    Member since:
    Aug 2010

    Posted 10 Mar 2011 Link to this post

    Hello Helen,

    thank your very much. Your last code block did the job :-)

    I really appreciate your help.

    Have a nice day.

    Vasssek
Back to Top