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

RadComboBox focus retained when clicking other control

4 Answers 64 Views
ComboBox
This is a migrated thread and some comments may be shown as answers.
Steve
Top achievements
Rank 1
Steve asked on 28 Aug 2012, 01:58 PM
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?

4 Answers, 1 is accepted

Sort by
0
Accepted
Ivana
Telerik team
answered on 30 Aug 2012, 10:43 AM
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.
0
Steve
Top achievements
Rank 1
answered on 30 Aug 2012, 01:28 PM
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>
0
Kiran
Top achievements
Rank 2
answered on 08 Oct 2018, 04:30 PM

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.

0
Attila Antal
Telerik team
answered on 10 Oct 2018, 06:38 PM
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.
Tags
ComboBox
Asked by
Steve
Top achievements
Rank 1
Answers by
Ivana
Telerik team
Steve
Top achievements
Rank 1
Kiran
Top achievements
Rank 2
Attila Antal
Telerik team
Share this question
or