Is there some other event that I can use? Or some way to make this event work?
Thanks.
3 Answers, 1 is accepted
This behavior is by design. Actually the item is not select through keyboard, only highlighted and its text appears in the input field.
I suggest you hook on OnClientKeyPressing event and check did you use arrow key. In this event you can execute your custom logic.
Hope this helps.
Greetings,
Rosi
the Telerik team
Instantly find answers to your questions at the new Telerik Support Center
Here is the event:
function OnClientSelectedIndexChanged(sender, args)
{
WWSHideElement(
'<%= pnlCreditCard.ClientID %>');
WWSHideElement(
'<%= pnlACH.ClientID %>');
if ( sender.get_selectedItem().get_index() == 1 )
WWSShowElement(
'<%= pnlCreditCard.ClientID %>');
if ( sender.get_selectedItem().get_index() == 2 )
WWSShowElement(
'<%= pnlACH.ClientID %>');
}
If the selected item doesn't really change when you press the up or down arrow key, then presumably "sender.get_selectedItem()" will not return the correct value.
I want to show/hide certain DIVs based on the selected payment type in the combobox. It confusing from a UI perspective to have the combobox value changed to "Credit Card" but have the page still showing ACH information. Everything worked fine with the standard combobox, but I was trying to go "all telerik" to get a more consistent look & feel. I guess I'll have to go back to the standard control if this functionality is not possible with the telerik control.
The OnClientSelectedIndexChanged event will fire after you choose the item via the arrow keys and click outside of RadComboBox or hit Enter. In this case get_selectedItem will be the item which you expected.
Still you can execute your logic before hitting Enter or clicking outside in the following way:
1. Hook on OnClientKeyPressing event.
2. Check if the arrow key is pressed.
3. Use get_highlightedItem() instead of get_selectedItem();
For example:
javascript
<script language="javascript" type="text/javascript"> |
function HandkeKeyPress(sender, eventArgs) |
{ |
var index = -1; |
if (eventArgs.keyCode == 38 ) |
{ |
item =sender.get_highlightedItem().get_index()-1; |
} |
if (eventArgs.keyCode == 40 ) |
{ |
item =sender.get_highlightedItem().get_index()+1; |
} |
if(index>-1) |
{ |
WWSHideElement('<%= pnlCreditCard.ClientID %>'); |
WWSHideElement('<%= pnlACH.ClientID %>'); |
if ( sender.get_highlightedItem().get_index() == 1 ) |
WWSShowElement('<%= pnlCreditCard.ClientID %>'); |
if ( sender.get_highlightedItem().get_index() == 2 ) |
WWSShowElement('<%= pnlACH.ClientID %>'); |
} |
} |
</script> |
aspx:
<telerik:RadComboBox |
ID="RadComboBox1" |
runat="server" |
OnClientKeyPressing="HandleKeyPress"> |
</telerik:RadComboBox> |
Hope this helps.
Regards,
Rosi
the Telerik team
Instantly find answers to your questions at the new Telerik Support Center