I'm using a radcombobox to populate items from a database on demand. All works well except for when EmptyMessage is set
The Problem:
On the first attempt to drop the box down, it displays no matches and nothing comes up in the list. The second dropdown attempt everything works perfectly. Happens only when the EmptyMessage property is set. I'm stumped.
----
Here is what my code looks like:
.aspx and javascript
Finally the codebehind:
Can anyone help me with what I'm doing wrong? Thanks in advance.
The Problem:
On the first attempt to drop the box down, it displays no matches and nothing comes up in the list. The second dropdown attempt everything works perfectly. Happens only when the EmptyMessage property is set. I'm stumped.
----
Here is what my code looks like:
.aspx and javascript
<telerik:RadComboBox ID="cboCities" runat="server" AutoPostBack="True" EnableLoadOnDemand="True" |
EnableVirtualScrolling="True" Height="200px" MarkFirstMatch="True" |
OnClientItemsRequesting="OnClientItemsRequesting" |
OnItemsRequested="cboCities_ItemsRequested" Filter="None" ShowMoreResultsBox="True" |
Width="240px" Font-Size="X-Small" AllowCustomText="True" |
EmptyMessage="Type a city name" Skin="Black"> |
<CollapseAnimation Duration="200" Type="OutQuint" /> |
</telerik:RadComboBox> |
function OnClientItemsRequesting(sender,e) |
{ |
if(sender.get_appendItems()) |
e.get_context().CustomText=""; |
else |
e.get_context().CustomText=sender.get_text(); |
} |
Finally the codebehind:
Protected Sub cboCities_ItemsRequested(ByVal sender As Object, ByVal e As RadComboBoxItemsRequestedEventArgs) |
Dim sql As String = "Select cityCode,cityName,State,Lat,Long from s_CityMaster WHERE Cityname LIKE '%" + e.Context("CustomText").ToString() + "%' ORDER BY CityName" |
Dim adapter As New SqlDataAdapter(sql, ConfigurationManager.AppSettings("BioDiasporaCS")) |
Dim data As New DataTable() |
adapter.Fill(data) |
Try |
Dim itemsPerRequest As Integer = 10 |
Dim itemOffset As Integer = e.NumberOfItems |
Dim endOffset As Integer = itemOffset + itemsPerRequest |
If endOffset > data.Rows.Count Then |
endOffset = data.Rows.Count |
End If |
If endOffset = data.Rows.Count Then |
e.EndOfItems = True |
End If |
Dim i As Integer = itemOffset |
While i < endOffset |
cboCities.Items.Add(New RadComboBoxItem(data.Rows(i)("cityName").ToString(), data.Rows(i)("cityName").ToString())) |
i = i + 1 |
End While |
If data.Rows.Count > 0 Then |
e.Message = [String].Format("Items <b>1</b>-<b>{0}</b> out of <b>{1}</b>", endOffset.ToString(), data.Rows.Count.ToString()) |
Else |
e.Message = "No matches" |
End If |
Catch |
e.Message = "No matches" |
End Try |
End Sub |
Can anyone help me with what I'm doing wrong? Thanks in advance.