I have a RadComboBox that I'm using to allow users to perform assisted searches. As they type in the combo box field, "search assist" values are populated in the drop down section. The user can either hit enter (or click a search button) or select one of the values in the drop down to perform a search. Let me rephrase and emphasize that the user can either use their freely entered text or select one of the suggested search terms.
If the user hits the enter key, I am capturing this with the OnClientKeyPressing event. Most of the time this works fine but the event fails to fire if I hit enter at the exact moment I see the "Loading..." text in the drop down. If I hit enter a fraction of a second before or after the loading text, it works normally.
Here is my combo box:
Here is my js method:
As you can see, I need to differentiate between selecting an item from the drop down list and the freely entered text.
Again, everything works except when I hit enter while I see the "Loading..." text in the drop down portion of the combo box. When I hit enter at that time, the event is not fired and nothing appears to happen. How do I handle this scenario with your control?
If the user hits the enter key, I am capturing this with the OnClientKeyPressing event. Most of the time this works fine but the event fails to fire if I hit enter at the exact moment I see the "Loading..." text in the drop down. If I hit enter a fraction of a second before or after the loading text, it works normally.
Here is my combo box:
<telerik:RadComboBox ID="ddlTextSearch" runat="server" Width="200px" CssClass="SearchControl" |
AllowCustomText="True" EnableLoadOnDemand="True" |
ShowDropDownOnTextboxClick="False" ShowToggleImage="False" |
onclientitemsrequesting="ddlTextSearch_ItemRequesting" |
OnClientKeyPressing="ddlTextSearch_HandleKeyPress" |
OnClientSelectedIndexChanged="ddlTextSearch_SelectionChanged" ZIndex="9900"> |
<WebServiceSettings Method="GetCompletionList" Path="~/TextSearchAutoComplete.aspx" /> |
</telerik:RadComboBox> |
<script type="text/javascript"> |
Telerik.Web.UI.RadComboBox.prototype._onInputCellClick = function(e) { |
if (this._enabled) { |
// if (this.get_text() !== this.get_emptyMessage()) |
// this.selectText(0, this.get_text().length); |
if (!this.get_dropDownVisible() && this._showDropDownOnTextboxClick) |
this._showDropDown(e); |
return true; |
} |
} |
</script> |
Here is my js method:
function ddlTextSearch_HandleKeyPress(sender, eventArgs) |
{ |
if(eventArgs.get_domEvent().keyCode == 13) |
{ |
var combo = $find("<%= ddlTextSearch.ClientID %>"); |
var ajaxManager = $find("<%= RadAjaxManager.GetCurrent(Page).ClientID %>"); |
if (combo && combo.get_highlightedItem() != null) |
{ |
ajaxManager.ajaxRequestWithTarget("<%= ddlTextSearch.UniqueID %>","<%= WebUtils.HttpRequestEventArguments.SearchAssist %>"); |
} |
else |
{ |
ajaxManager.ajaxRequestWithTarget("<%= ddlTextSearch.UniqueID %>","<%= WebUtils.HttpRequestEventArguments.Search %>"); |
} |
} |
} |
As you can see, I need to differentiate between selecting an item from the drop down list and the freely entered text.
Again, everything works except when I hit enter while I see the "Loading..." text in the drop down portion of the combo box. When I hit enter at that time, the event is not fired and nothing appears to happen. How do I handle this scenario with your control?