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

Defocus ComboBox on Option Selection

4 Answers 109 Views
ComboBox
This is a migrated thread and some comments may be shown as answers.
Levi
Top achievements
Rank 1
Levi asked on 22 Apr 2009, 05:57 PM
Is there a way to set focus away from a combobox after a user selects an item? I want the ComboBox to lose focus immediately after the user makes a selection.


4 Answers, 1 is accepted

Sort by
0
Shinu
Top achievements
Rank 2
answered on 23 Apr 2009, 04:45 AM
Hi Levi,

Try out the following code snippet for setting the focus away from RadComboBox on selecting an item.

ASPX:
 
<telerik:RadComboBox ID="RadComboBox1" runat="server" OnClientSelectedIndexChanged="OnClientSelectedIndexChanged" >  
       <Items>  
            <telerik:RadComboBoxItem Text="Item1"  Value="Item1" runat="server"></telerik:RadComboBoxItem>  
            <telerik:RadComboBoxItem Text="Item2" Value="Item2" runat="server"></telerik:RadComboBoxItem>  
            <telerik:RadComboBoxItem Text="Item3" Value="Item3" runat="server"></telerik:RadComboBoxItem>                        
       </Items>  
</telerik:RadComboBox> 

JavaScript:
 
<script type="text/javascript"
function  OnClientSelectedIndexChanged(sender, args) 
  var dom = sender.get_inputDomElement(); 
  dom.blur(); 
</script> 

Thanks,
Shinu.
0
Levi
Top achievements
Rank 1
answered on 23 Apr 2009, 04:57 AM
Thanks for this, although the code does not seem to have any effect. I checked to make sure it was getting called and everything seems as expected. It does not raise an error though. When the code gets called it is as if nothing happened. I tried both IE and Firefox. Any ideas?
0
Shinu
Top achievements
Rank 2
answered on 24 Apr 2009, 12:48 PM
Hi Levi,

I tried above code found that it is working fine in Firefox and IE6. The RadComboBox loses focus on selection changing. Could you paste the code which you tried if it is different from the code I tried?

Thanks,
Shinu.
0
ManniAT
Top achievements
Rank 2
answered on 24 Apr 2009, 04:26 PM
Hi Levi,

could it be that you do a callback / postback with your combobox?
If so there are different approaches to achieve what you want.

I couldn't test the function Shinu provided (I'm almost sure it works) - but I do something like this - I set the focus to a different control on the page - which works.

Regards

Manfred
Tags
ComboBox
Asked by
Levi
Top achievements
Rank 1
Answers by
Shinu
Top achievements
Rank 2
Levi
Top achievements
Rank 1
ManniAT
Top achievements
Rank 2
Share this question
or