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

[Solved] HELP! Comboxbox entered text changes to selected text

4 Answers 110 Views
ComboBox
This is a migrated thread and some comments may be shown as answers.
Tim
Top achievements
Rank 1
Tim asked on 04 May 2009, 03:00 PM
Here is the deal.

1. I have a RadCombo on aspx page (no materpage, usercontrol etc)
2. I allow custom text and there are items loaded from the db already in the dropdown list
3. I have the "enter" key fired up to run search on hitting enter

Everything works like a champ, EXCEPT :-) if I happen to roll my mouse over or even select an item in the list, then click back in the combobox to "enter custom text" it allows me to enter the custom text and when I hit enter the code behind reads that custom text and all works like a champ. BUT the text that shows while the server is "working" is whatver is selected in the list.

Make sense? So if I select "Tim" in the drop down list and then type over "Tim" and type "John" it searches for John, but once I hit enter to invoke the search, the combobox text changes back to "Tim", once the server comes back with results, "John" is back in the combobox, works, BUT confusing because user thinks, hey I just entered "John" and "Tim" keeps showing up after I hit "ENTER"

Any setting I am missing, for I have spent hours trying to stop this...

4 Answers, 1 is accepted

Sort by
0
Accepted
Atanas Korchev
Telerik team
answered on 05 May 2009, 01:46 PM
Hello Tim,

I am not sure how to reproduce the problem at my end. Could you see the same in any of our online demos?

Regards,
Albert
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
0
Tim
Top achievements
Rank 1
answered on 05 May 2009, 02:09 PM
No it does not do it in the online example you sent, but it doesn't have a "key press" event fired to it, meaning I can type in the online example and mine hit the submit button and it works fine, mine and your example, it's when this function (below) is attached and I hit ENTER it does what's described above: (this function works and searches the correct value typed in, it just shows the text selected previous in the dropdownlist, so it gets confusing to the user, ya know?, if nothing is ever selected in the dropdown list, I do get the "searching please wait.." text in the function below, it's only if the mouse rolls over and you click anything in the dropdown, weird...)

function RadComboKeyPress(sender, eventArgs) {
            var keyCode = eventArgs.get_domEvent().keyCode;
            if (keyCode == 13) {
                var prm = Sys.WebForms.PageRequestManager.getInstance();
                prm._doPostBack('ibtnSearch', '');
                var combo = $find("<%= RadComboBox1.ClientID %>");
                combo.set_text("searching please wait...");
                return false;
            }
        }

Then the control has OnClientKeyPressing="RadComboKeyPress"

Thanks for you help BTW...
0
Tim
Top achievements
Rank 1
answered on 06 May 2009, 01:52 PM
Ok I got it, finally. Here is what I had to add to my function: (notice the "combo.clearSelection();" )

function RadComboKeyPress(sender, eventArgs) {
            var keyCode = eventArgs.get_domEvent().keyCode;
            if (keyCode == 13) {
                var prm = Sys.WebForms.PageRequestManager.getInstance();
                prm._doPostBack('ibtnSearch', '');
                var combo = $find("<%= RadComboBox1.ClientID %>");
                combo.clearSelection();
                combo.set_text("searching please wait...");
                return false;
            }
        }
0
Accepted
Simon
Telerik team
answered on 06 May 2009, 02:55 PM
Hello Tim,

Indeed using clearSelection in this case works because when Enter is hit RadComboBox automatically selects the highlighted Item. Since you move the mouse through the drop down before that there is a highlighted Item. The clearSelection method clears the highlighted, so it avoids the undesired behavior.

Greetings,
Simon
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
Tags
ComboBox
Asked by
Tim
Top achievements
Rank 1
Answers by
Atanas Korchev
Telerik team
Tim
Top achievements
Rank 1
Simon
Telerik team
Share this question
or