I am trying to use both the AutoComplete and LoadOnDemand features of the RadComboBox. I have a huge list of popular bands (about 20,000 entries in the database), and I want users to be able to select multiple items from the list by typing a few characters of the band's name.
Please help!
Thanks
Paul
The code I have now is:
<telerik:RadComboBox runat="server" ID="radSimilarArtists" EnableLoadOnDemand="true"
EnableVirtualScrolling="true" EnableTextSelection="true" Width="300" MarkFirstMatch="True"
AutoCompleteSeparator="," ShowMoreResultsBox="true" AllowCustomText="false" ShowDropDownOnTextboxClick="false"
OnItemsRequested="radSimilarArtists_ItemsRequested" Skin="Default" />
And the code behind
protected void radSimilarArtists_ItemsRequested(object o, RadComboBoxItemsRequestedEventArgs e)
{
MegaService megaClass = new MegaService();
string textEntered = e.Text;
DataTable data = megaClass.getSimilarArtists(textEntered).Tables["similarartists"];
int itemOffset = e.NumberOfItems;
int endOffset = Math.Min(itemOffset + ItemsPerRequest, data.Rows.Count);
e.EndOfItems = endOffset == data.Rows.Count;
for (int i = itemOffset; i < endOffset; i++)
{
radSimilarArtists.Items.Add(new RadComboBoxItem(data.Rows[i]["name"].ToString(), data.Rows[i]["id"].ToString()));
}
e.Message = GetStatusMessage(endOffset, data.Rows.Count);
}
private static string GetStatusMessage(int offset, int total)
{
if (total <= 0)
return "No matches";
return String.Format("Items <b>1</b>-<b>{0}</b> out of <b>{1}</b>", offset, total);
}