I have my ItemsRequested handler working where on start of the page, this method gets hit and it loads the first set of items. Scrolling through the list works well and each new page is requested and starts loading.
However, if I go into the combo box and right away I starting typing something which does not appear in the first page of results, the item is listed but I am no longer able to change the results and see the new matches appear in the list of the combo box.
The list is approx. 3,000 records, here are the relevant snips:
protected void RadComboBoxMedicationName_ItemsRequested(object sender, RadComboBoxItemsRequestedEventArgs e)
{
Database db = DatabaseFactory.CreateDatabase();
RadComboBox r = sender as RadComboBox;
DbCommand cmd = db.GetSqlStringCommand("SELECT Id, Description FROM refMedType WHERE Description LIKE '" + e.Context["Text"].ToString() + "%'");
DataTable data = (DataTable)(db.ExecuteDataSet(cmd)).Tables[0]; ;
try
{
int itemsPerRequest = 25;
int itemOffset = e.NumberOfItems;
int endOffset = itemOffset + itemsPerRequest;
if (endOffset > data.Rows.Count)
{
endOffset = data.Rows.Count;
}
if (endOffset == data.Rows.Count)
{
e.EndOfItems =
true;
}
else
{
e.EndOfItems =
false;
}
for (cint i = itemOffset; i < endOffset; i++)
{
r.Items.Add(
new RadComboBoxItem(data.Rows[i]["Description"].ToString(), data.Rows[i]["Description"].ToString()));
}
if (data.Rows.Count > 0)
{
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";
}
}
catch (Exception ex)
{
e.Message =
"No matches";
}
}
<telerik:RadComboBox ID="RadComboBoxMedicationName" ShowWhileLoading="true" EmptyMessage="Enter medication name" Text='<%# Bind( "MedicationName" ) %>' LoadingMessage="Loading..." runat="server" Width="250px" Height="200px" AllowCustomText="True" ShowMoreResultsBox="true" EnableLoadOnDemand="True" MarkFirstMatch="True" OnItemsRequested="RadComboBoxMedicationName_ItemsRequested" EnableVirtualScrolling="true" />
<asp:RequiredFieldValidator ID="RequiredFieldValidatorMedicationName" runat="server" ControlToValidate="RadComboBoxMedicationName" Display="Dynamic" ErrorMessage="RequiredFieldValidator" ToolTip="Medication required."><br />* Medication required.</asp:RequiredFieldValidator>