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

Combobox Dropdown doesn't show after item is clicked

1 Answer 60 Views
ComboBox
This is a migrated thread and some comments may be shown as answers.
Web Services
Top achievements
Rank 2
Web Services asked on 20 Nov 2013, 08:42 PM
I have a combo box inside an ajax panel like so
<telerik:RadScriptManager ID="manager" runat="server"></telerik:RadScriptManager>
            <telerik:RadAjaxPanel ID="RadAjaxPanel3" runat="server" LoadingPanelID="RadAjaxLoadingPanel1">
            <telerik:RadComboBox ID="userInput" runat="server" AllowCustomText="True" CausesValidation="false" ShowToggleImage="False"
                ShowMoreResultsBox="true" EnableLoadOnDemand="True" MarkFirstMatch="True"
                OnItemsRequested="LoadSearch"
                ErrorMessage="Value not Found" AutoPostBack="True" Width="300">
                <CollapseAnimation Duration="1000" Type="InBack" />
            </telerik:RadComboBox>
</telerik:RadAjaxPanel>
        <telerik:RadAjaxLoadingPanel ID="RadAjaxLoadingPanel1" runat="server" SkinID="Hay"
        Height="25px" Transparency="1" BackgroundPosition="Center" >
        <img alt="Loading..." src="../images/loading.gif" style="border: 0px;" />
    </telerik:RadAjaxLoadingPanel>

When I click in it, it loads items and if I start typing, it also searches correctly. However, once I select an item, no more items will load. Even if I delete text, nothing comes up. Here's my code behind

protected void Page_Load(object sender, EventArgs e)
{
 
    if (!Page.IsPostBack)
    {
         
 
        userInput.DataSource = GetCustomers();
        userInput.DataValueField = "Key";
        userInput.DataTextField = "Value";
        userInput.DataBind();
    }//if !page.ispost
 
}//PageLoad
 
protected void LoadSearch(object sender, RadComboBoxItemsRequestedEventArgs e)
{
  
    //get the list based on the search
    IEnumerable<Vw_CustomersSearchView> customers = DbRepository.GetCustomersSearchView().Where(c => c.Customer.Contains(e.Text));
 
    //how many items we'll show
    int itemsPerReq = 10;
 
    //keep count of the items
    int count = 0;
 
    RadComboBox box = (RadComboBox)sender;
    box.Items.Clear();
 
 
    //make sure we have at least one record
    if (customers.Count() > 0)
    {
        //now add any customer items
        foreach (var i in customers)
        {
 
            //if we're above 10, exit the loop
            if (count >= itemsPerReq)
            {
                break;
            }//if count > itemsper
 
            //if we're here, add the items
            box.Items.Add(new RadComboBoxItem(i.Customer, i.UserName));
 
            count++;
        }//foreach
    }//if customers.count
    else
    {
        e.Message = "No matches";
    }
 
 
}//LoadSearch
 
/// <summary>
/// this returns a dictionary of the customers for the customer dropdown
/// </summary>
/// <returns></returns>
protected Dictionary<string, string> GetCustomers()
{
 
    Dictionary<string, string> customersList = new Dictionary<string, string>();
 
    //now add the items
    var cTable = DbRepository.GetActiveCustomers().Where(a => a.LoyaltyCardNumber != null).Select(a => new {a.UserName, a.FirstName, a.LoyaltyCardNumber, a.LastName});
 
    foreach (var i in cTable)
    {
        string name = String.Format("{0}{1}{2}{3}{4}", i.FirstName, " ", i.LastName, " - ", i.LoyaltyCardNumber);
        customersList.Add(i.UserName, name);
    }//foreach
 
    return customersList;
 
}//GetCustomers
 
/// <summary>
/// if they picked an item in the combox box, repopulate it
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void userInput_SelectedIndexChanged(object sender, RadComboBoxSelectedIndexChangedEventArgs e)
{
    userInput.DataSource = GetCustomers();
    userInput.DataValueField = "Key";
    userInput.DataTextField = "Value";
    userInput.DataBind();
}//resetPasswordButtonClick

Here's a video of what's happening. How do I make it pull the dropdown again, even after you select an item. https://dl.dropboxusercontent.com/u/4979877/combo.swf




1 Answer, 1 is accepted

Sort by
0
Nencho
Telerik team
answered on 26 Nov 2013, 07:27 AM
Hello,

I am afraid that after several tests, base on the provided code snippet, I was unable to replicate the demonstrated issue locally. However, I noticed that you are populating the RadComboBox at the PageLoad event, while a LoadOnDemand functionality is enabled. The purpose of the LoadOnDemand functionality is to push the RadComboBox to request its underlying datasource, once the user types in the input of the control or expands the dropdown. Therefore, my suggestion would be to choose one approach for populating the control with data.

Regards,
Nencho
Telerik
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to the blog feed now.
Tags
ComboBox
Asked by
Web Services
Top achievements
Rank 2
Answers by
Nencho
Telerik team
Share this question
or