This is a migrated thread and some comments may be shown as answers.

Load On Demand Issue

1 Answer 36 Views
ComboBox
This is a migrated thread and some comments may be shown as answers.
Adam
Top achievements
Rank 1
Adam asked on 18 Apr 2011, 06:01 PM

I am relatively knew to the Telerik controls but have been a developer for several years. I want to implement a load on demand combo box for my newest project(well several really), the control will load from a page method. I got the control to load initially, but as you type the dropdown just bounces a little without narrowing the search or showing any type of error. Below is the code that is currently being used for the control, and page method.

private const int ItemsPerRequest = 20;

[WebMethod]
public static RadComboBoxData GetContributors(RadComboBoxContext context)

     DataTable data = GetContributors(); 
     RadComboBoxData comboData = new RadComboBoxData();
     int itemOffset = context.NumberOfItems;
     int endOffSet = Math.Min(itemOffset + ItemsPerRequest, data.Rows.Count);
     comboData.EndOfItems = endOffSet == data.Rows.Count;

     List<RadComboBoxItemData> results = new List<RadComboBoxItemData>(endOffSet - itemOffset);
     for (int i = itemOffset; i < endOffSet; i++)
     {
          RadComboBoxItemData itemData = new RadComboBoxItemData();
          itemData.Text = data.Rows[i]["Contributor"].ToString();
          itemData.Value = data.Rows[i]["ContributorID"].ToString();
          results.Add(itemData); 
     }

     comboData.Message = GetStatusMessage(endOffSet, data.Rows.Count);
     comboData.Items = results.ToArray();
     return comboData;

}

private static string GetStatusMessage(int offSet, int total)

     if (total <= 0)
     {
         return "No matches";
     } 
     else
     { 
         return string.Format("Items <b>1</b>-<b>{0}</b> out of <b>{1}</b>", offSet, total);
     }
}

<telerik:RadAjaxPanel ID="RadAjaxPanel1" runat="server" Height="200px" Width="300px"> 
<telerik:RadComboBox ID="radcboAutoContributorNames" EmptyMessage="Please enter contributor name" Width="200px"            MaxHeight="140px" EnableLoadOnDemand="true" ShowMoreResultsBox="true" EnableVirtualScrolling="true" Runat="server">
<WebServiceSettings Method="GetContributors" Path="Default.aspx" />
</telerik:RadComboBox>
</telerik:RadAjaxPanel>

1 Answer, 1 is accepted

Sort by
0
Adam
Top achievements
Rank 1
answered on 18 Apr 2011, 07:22 PM
I think I figure it out, it was a simply database issue that I over looked.
Tags
ComboBox
Asked by
Adam
Top achievements
Rank 1
Answers by
Adam
Top achievements
Rank 1
Share this question
or