I have the following code setup in the onKeyPressing event of my RadComboBox. When I execute it, if there are multiple results from the callback, the dropdown quickly opens and shuts (line 65 is where I open the combo box). Based on my interpretation of the client side events, the combo box should remain open.
I've also tried executing the .commitChanges() call before the .showDropDown() as well as attempted to event_args.setCancel(true), but neither worked.
What am I missing?
01.
function rrKeyPress(sender, eventArgs) {
02.
if
(eventArgs.get_domEvent().keyCode
=
=
13
) {
03.
04.
var clientId
=
sender.get_id();
05.
/
/
var comboBox
=
document.getElementById(clientId);
06.
07.
var comboBox
=
$find(clientId);
08.
09.
var userEntry
=
comboBox._text;
10.
var matches
=
document.getElementById(
'txtNumEntries'
).value;
11.
12.
var epmsDataHandler
=
'<%= ResolveUrl("~/EPMSDataHandler.ashx") %>'
;
13.
var randomNum
=
Math.round(
+
new Date()
/
1000
);
14.
15.
var xhReq
=
new XMLHttpRequest();
16.
17.
sURL
=
epmsDataHandler
+
"?userEntry="
+
userEntry
+
"&matches="
+
matches
+
"&randomNum="
+
randomNum;
18.
19.
xhReq.open(
"GET"
, sURL, false);
20.
xhReq.send(null);
21.
22.
comboBox.clearItems();
23.
24.
try
{
25.
var response
=
xhReq.responseText;
26.
var fileError
=
'ERRORMESSAGE'
;
27.
if
(xhReq.responseText.substr(
0
, fileError.length)
=
=
fileError) {
28.
alert(xhReq.responseText.substr(fileError.length
+
1
, xhReq.responseText.length
-
fileError.length));
29.
}
30.
else
{
31.
var jsonData
=
$.parseJSON(response);
32.
var numMatches
=
0
;
33.
var selectedItem
=
new Telerik.Web.UI.RadComboBoxItem();
34.
var firstDisplayName
=
"";
35.
36.
for
(var x
=
0
; x < jsonData.matches.length; x
+
+
) {
37.
var match
=
jsonData.matches[x];
38.
39.
var comboItem
=
new Telerik.Web.UI.RadComboBoxItem();
40.
41.
var displayName
=
match.fullName
+
" - "
+
match.id
+
" - "
+
match.rank;
42.
43.
if
(x
=
=
0
)
44.
{
45.
firstDisplayName
=
displayName;
46.
}
47.
48.
comboItem.set_value(match.id);
49.
comboItem.set_text(displayName);
50.
51.
comboBox.get_items().add(comboItem);
52.
numMatches
+
+
;
53.
selectedItem
=
=
comboItem;
54.
}
55.
56.
if
(numMatches
=
=
1
)
57.
{
58.
var item
=
comboBox.findItemByText(firstDisplayName);
59.
if
(item) {
60.
item.select();
61.
}
62.
}
63.
else
64.
{
65.
comboBox.showDropDown();
66.
}
67.
68.
document.getElementById(
'lblNumMatches'
).innerHTML
=
numMatches;
69.
70.
comboBox.commitChanges();
71.
72.
}
73.
}
74.
catch (ex) { alert(
"Error getting matching values - "
+
ex.message);
return
false; }
75.
}
76.
}