Load On Demand Issue

2 posts, 0 answers
  1. Adam
    Adam avatar
    6 posts
    Member since:
    Apr 2011

    Posted 18 Apr 2011 Link to this post

    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>
  2. Adam
    Adam avatar
    6 posts
    Member since:
    Apr 2011

    Posted 18 Apr 2011 Link to this post

    I think I figure it out, it was a simply database issue that I over looked.
Back to Top