RadComboBox focus retained when clicking other control

5 posts, 1 answers
  1. Steve
    Steve avatar
    2 posts
    Member since:
    Aug 2012

    Posted 28 Aug 2012 Link to this post

    We have a RadComboBox with CheckBoxes set true. The drop down stays open after checking a checkbox so you can check more, which is fine. The problem is that when you click in a textbox while the dropdown is open an entry cursor appears in the textbox briefly as it gets focus but clears as the textbox loses focus when the combobox dropdown closes. It is necessary to click the textbox a second time before typing into it. Alternatively the combobox arrow must first be clicked to close the dropdown before clicking the textbox to transfer the focus.

    Is there some way to prevent the combobox from retaining the focus when another control is clicked?
  2. Answer
    Ivana
    Admin
    Ivana avatar
    657 posts

    Posted 30 Aug 2012 Link to this post

    Hi Steve,

    For some reason the TextBox does not get focused on the first click on it when viewed under IE. The following JavaScript, however, should work fine (I have been testing this behavior with RadTextBox):
    function pageLoad() {
        $telerik.$(".riTextBox")[0].onclick = function () {
            $find("RadTextBox1").focus();
        }
    }
    <telerik:RadComboBox runat="server" ID="RadComboBox2" CheckBoxes="true">
        <Items>
            <telerik:RadComboBoxItem Text="1" />
            <telerik:RadComboBoxItem Text="2" />
        </Items>
    </telerik:RadComboBox>
    <telerik:RadTextBox ID="RadTextBox1" runat="server">
        <ClientEvents OnFocus="clientFocus" />
    </telerik:RadTextBox>

    I hope this will be helpful.

    Kind regards,
    Ivana
    the Telerik team
    If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now.
  3. Steve
    Steve avatar
    2 posts
    Member since:
    Aug 2012

    Posted 30 Aug 2012 Link to this post

    Thanks. This put me on the right track. Though my textboxes were ASP ones I could do the following to solve the problem.

    <script language="javascript" type="text/javascript">
      function ForceFocus(textbox) {
        $get(textbox).focus();
      }
    </script>

    <
    asp:TextBox ID="SubjectTextBox" runat="server" Width="300" onkeydown="OnMessageKeyDown()"
      onkeyup="OnMessageKeyUp()" onclick="ForceFocus('SubjectTextBox')">
    </asp:TextBox>
  4. Kiran
    Kiran  avatar
    57 posts
    Member since:
    Oct 2018

    Posted 08 Oct 2018 in reply to Ivana Link to this post

    Hi Ivana,

    with regards to your post; Client events OnFocus="clientFocus". Where is clientfocus in the javascript? Isn't it not JS function? I see function pageLoad() in JS but not client focus. Please help. I have been struggling to set focus in the Batch edit of my textbox since last week but have been unsuccessful. I tried itemdatabound and itemcreated and many other solutions suggested with regards to the setting of focus.

     

    Thank you,

    Kiran.

  5. Attila Antal
    Admin
    Attila Antal avatar
    593 posts

    Posted 10 Oct 2018 Link to this post

    Hi Kiran,

    The clientFocus event handler is only serving as a proof that the control got focused after implementing the first ForceFocus logic.

    Here is an example of the clientFocus function:
    function clientFocus(){
        alert("textbox got focused :)")
    }

    Also, I can see that you have opened a formal support ticket for this issue. I advise that we discuss the details in that ticket and once we have the solution, we will share it in this thread,  for the community.

    Thread related to: RADGRID : Do Set Focus in In-Mode-Editing

    Kind regards,
    Attila Antal
    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.
Back to Top