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

Rad Combo Box And How Take It's Focus Off

4 Answers 110 Views
ComboBox
This is a migrated thread and some comments may be shown as answers.
Majid Darab
Top achievements
Rank 1
Majid Darab asked on 09 Feb 2010, 05:25 PM
hi my dear friends:
i have two radcombobox on my page and i am controling their focus by jquery...
also i have some code on their OnClientFocus , therefore focus and blur are so important ...
my aspx and jquery code are like this : (without RadComboBox -> OnClientFocus )

<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="WebForm4.aspx.cs" Inherits="Darman.WebForm4" %> 
 
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> 
 
<html xmlns="http://www.w3.org/1999/xhtml" > 
<head runat="server"
    <title></title
        <script src="../JQuery/jquery-1.4.1.js" language="javascript" type="text/javascript"></script> 
 
    <script type="text/javascript"
        $(function() { 
        $('input[id$=RadComboBox1_Input]').focus(); 
        $('input[id$=RadComboBox1_Input]').select(); 
        $('input[id$=RadComboBox1_Input]').bind('keyup', function(e) { 
                var code = (e.keyCode ? e.keyCode : e.which); 
                if (code == 13) { 
                    $('input[id$=RadComboBox1_Input]').blur(); 
                    $('input[id$=RadComboBox2_Input').focus(); 
                    $('input[id$=RadComboBox2_Input]').select(); 
                } 
            }); 
            $('input[id$=RadComboBox2_Input]').bind('keyup', function(e) { 
                var code = (e.keyCode ? e.keyCode : e.which); 
                if (code == 38) { 
                    $('input[id$=RadComboBox2_Input]').blur(); 
                    $('input[id$=RadComboBox1_Input').focus(); 
                    $('input[id$=RadComboBox1_Input]').select(); 
                } 
            }); 
        }); 
            </script> 
</head> 
<body> 
    <form id="form1" runat="server"
    <telerik:RadScriptManager ID="RadScriptManager1" runat="server"
    </telerik:RadScriptManager> 
    <div> 
        <telerik:RadComboBox ID="RadComboBox1" runat="server" Skin="Outlook"
            <Items> 
                <telerik:RadComboBoxItem runat="server" Text="RadComboBoxItem1"  
                    Value="RadComboBoxItem1" /> 
                <telerik:RadComboBoxItem runat="server" Text="RadComboBoxItem2"  
                    Value="RadComboBoxItem2" /> 
                <telerik:RadComboBoxItem runat="server" Text="RadComboBoxItem3"  
                    Value="RadComboBoxItem3" /> 
                <telerik:RadComboBoxItem runat="server" Text="RadComboBoxItem4"  
                    Value="RadComboBoxItem4" /> 
            </Items> 
        </telerik:RadComboBox> 
        <telerik:RadComboBox ID="RadComboBox2" runat="server" Skin="Office2007"
            <Items> 
                <telerik:RadComboBoxItem runat="server" Text="RadComboBoxItem1"  
                    Value="RadComboBoxItem1" /> 
                <telerik:RadComboBoxItem runat="server" Text="RadComboBoxItem2"  
                    Value="RadComboBoxItem2" /> 
                <telerik:RadComboBoxItem runat="server" Text="RadComboBoxItem3"  
                    Value="RadComboBoxItem3" /> 
                <telerik:RadComboBoxItem runat="server" Text="RadComboBoxItem4"  
                    Value="RadComboBoxItem4" /> 
            </Items> 
        </telerik:RadComboBox> 
    </div> 
    </form> 
</body> 
</html> 
 

it seems that radcombo box can not foreget it's focus and stick with that , therefore when i play with 2 buttons (enter=13 and upper key=38 as you see in the upper code - Jquery) For Changing Their Focus so RadComboBox OnClientFocus does not fire until i click on my page and Click On the RadComboBox Again...
These Lines do not work:
1-$('input[id$=RadComboBox1_Input]').blur(); 
2-$('input[id$=RadComboBox2_Input]').blur();
how can i take focus off from radcombo box and  destroy it's highlight?
thanks a lot




4 Answers, 1 is accepted

Sort by
0
Majid Darab
Top achievements
Rank 1
answered on 14 Feb 2010, 10:52 AM
any idea?
0
Oleg Slyusarchuk
Top achievements
Rank 1
answered on 26 Feb 2010, 06:58 PM
The same issue.
I tried to use

CloseDropDownOnBlur

 

="true"
but I dont' see any effect.

Instead of  $('input[id$=RadComboBox1_Input]').blur(); 
I'd suggest using
$('#divWithCombos').click(); 
Where divWithCombos is Id of the div where you place your combos.

 

0
Majid Darab
Top achievements
Rank 1
answered on 27 Feb 2010, 05:37 PM
i am following this thread every minute (i mean every day)   :)
0
John
Top achievements
Rank 1
answered on 25 Oct 2011, 07:33 PM
I know this thread is months old, but I recently had to solve the same problem.

Everything up to domObj.focus(); will focus the element.

Everything after that is to select all of the text.

I'm still not sure what causes the exception on domObj.select(), but it happens intermittently, and the catch is an alternate way to select all the text that also throws an exception intermittently. Using both has been 100% reliable thus far (and it's been a few months).

function SetFocusRadCombo(clientId) {
	var x = $find(clientId);
	var domObj = x.get_inputDomElement();
	domObj.focus();
	try {
		domObj.select();
	}
	catch (err) {
		x.selectText(0, x.get_text().length);
	};
}
Tags
ComboBox
Asked by
Majid Darab
Top achievements
Rank 1
Answers by
Majid Darab
Top achievements
Rank 1
Oleg Slyusarchuk
Top achievements
Rank 1
John
Top achievements
Rank 1
Share this question
or