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

Problem with Radcombo auto-selected matched item on close

3 Answers 104 Views
ComboBox
This is a migrated thread and some comments may be shown as answers.
Ruban
Top achievements
Rank 1
Ruban asked on 11 Jul 2008, 04:24 PM
I'm having a bit of a problem with a radcombobox.

The dropdown hides itself away neatly when the user clicks away on the page (onblur) BUT... if the current combobox text matches an item in the list, it's automatically selecting it.  This isn't the behaviour I expected - surely it should only "select" an item when a user clicks on it?

Further notes:
* I'm running the latest version (2008.1.619.20)
* I have tried setting MarkFirstMatch to true/false (no difference)
* I have tried setting AllowCustomText to true/false (no difference)
* Calling sender.clearSelection() onblur is a workaround, but this loses the user's search text, which we don't want.

Please advise!

3 Answers, 1 is accepted

Sort by
0
Rosi
Telerik team
answered on 14 Jul 2008, 10:26 AM
Hello Ruban,

RadComboBox selects a new item on blur if the text of the combo is changed. This behavior is by design.

I suggest you subscribe to the  OnClientBlur event of RadComboBox and get its text there. Then you can restore it in the event handler of  the OnClientSelectedIndexChanged event.

For example:
<script type=text/javascript> 
var combotext ="";  
 
function OnClientBlur(sender,e)  
{  
    combotext = sender.get_text();  
}  
 
function OnClientSelectedIndexChanged(sender,e)  
{  
    if( combotext !="" )  
        sender.set_text(combotext );  
}  
 
</script> 
 


Regards,
Rosi
the Telerik team

Instantly find answers to your questions at the new Telerik Support Center
0
Ruban
Top achievements
Rank 1
answered on 14 Jul 2008, 02:54 PM
Thanks for your reply Rosi.  I've tried applying that code, but it doesn't actually seem to do anything at all, beyond recording what text the user has entered.  Did you mean for me to keep the code I'd already written clearing the text on blur?  If I do that the OnClientSelectedIndexChanged event doesn't fire.

Just to clarify, what I want is to prevent the combo box from "selecting" the item when the user clicks away from the control.  In other words, I only want them to be able to select an item by explicitly clicking on the item in the dropdown list.


PS - I'm still surprised that the default action is to fire a selected index change when the user hasn't actually selected anything.  That seems counterintuitive to me (and all our product engineers here).  We'd love this to be optional behaviour, if you could pass that feedback on!
0
Rosi
Telerik team
answered on 17 Jul 2008, 01:50 PM
Hi Ruban,

Yes,you are right. I have modified the code. Please find the attached project which works as expected. You can download it and try it.

Best wishes,
Rosi
the Telerik team

Instantly find answers to your questions at the new Telerik Support Center
Tags
ComboBox
Asked by
Ruban
Top achievements
Rank 1
Answers by
Rosi
Telerik team
Ruban
Top achievements
Rank 1
Share this question
or