Combo box related issue

2 posts, 0 answers
  1. Kishore
    Kishore avatar
    7 posts
    Member since:
    Apr 2014

    Posted 17 May 2014 Link to this post

          I am using telerik combo box in my application. I fill combo box using service. I want to restrict user to enter any characters in combo box after selecting from dropdown. please suggest me is there any properties to disable.

    here is my code:
    ​ <telerik:RadComboBox ID="comsystemstatus" runat="server" EmptyMessage="Select" EnableLoadOnDemand="true"
    ShowMoreResultsBox="true" AllowCustomText="false"
    <WebServiceSettings Method="GetFaci_SystemStatus" Path="CaseService.asmx" />

    and my service:

    public RadComboBoxData GetFaci_SystemStatus(RadComboBoxContext context)
    EDSMESS_User_Information EDSMESS_User = new EDSMESS_User_Information();
    string query = "";
    query += "SELECT distinct Faci_SystemStatus FROM FACI where Faci_SystemStatus LIKE '" + context.Text + "' + '%' and Faci_SystemStatus Is Not Null ";
    DataSet ds = new DataSet();
    ds = EDSMESS_User.GetEDSMESSData(query);
    List<RadComboBoxItemData> result = new List<RadComboBoxItemData>(context.NumberOfItems);
    RadComboBoxData comboData = new RadComboBoxData();
    int itemsPerRequest = 10;
    int itemOffset = context.NumberOfItems;
    int endOffset = itemOffset + itemsPerRequest;
    if (endOffset > ds.Tables[0].Rows.Count)
    endOffset = ds.Tables[0].Rows.Count;
    if (endOffset == ds.Tables[0].Rows.Count)
    comboData.EndOfItems = true;
    comboData.EndOfItems = false;
    result = new List<RadComboBoxItemData>(endOffset - itemOffset);
    for (int i = itemOffset; i < endOffset; i++)
    RadComboBoxItemData itemData = new RadComboBoxItemData();
    itemData.Text = ds.Tables[0].Rows[i]["Faci_SystemStatus"].ToString();
    itemData.Value = ds.Tables[0].Rows[i]["Faci_SystemStatus"].ToString();


    if (ds.Tables[0].Rows.Count > 0)
    comboData.Message = String.Format("Items <b>1</b>-<b>{0}</b> out of <b>{1}</b>", endOffset.ToString(), ds.Tables[0].Rows.Count);
    comboData.Message = "No matches";
    catch (Exception e)
    comboData.Message = e.Message;

    comboData.Items = result.ToArray();
    return comboData;
  2. Boyan Dimitrov
    Boyan Dimitrov avatar
    1728 posts

    Posted 21 May 2014 Link to this post


    I would suggest using the RadComboBox client-side event function OnClientKeyPressing to prevent typing in the RadComboBox. So basically you can have a Boolean variable that shows whether an item is selected from the drop down list and based on that variable to execute the following code
    function OnClientKeyPressing(sender, args) {
       //execute this code block if user is selected an item

    //markup code
    <telerik:RadComboBox ID="comsystemstatus" runat="server" EmptyMessage="Select" EnableLoadOnDemand="true" OnClientKeyPressing="OnClientKeyPressing"
              ShowMoreResultsBox="true" AllowCustomText="false"
              <WebServiceSettings Method="GetItems" Path="WebService.asmx" />

    Boyan Dimitrov

    Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

Back to Top