RadComboBox not showing EmptyMessage

10 posts, 0 answers
  1. Karl Rohrbach
    Karl Rohrbach avatar
    20 posts
    Member since:
    Oct 2009

    Posted 17 Aug 2010 Link to this post

    I must be doing something wrong.  I have a RadComboBox and it is showing the first item in the list bound to it vs. EmptyMessage.  Any help would be appreciated.  In the below example, I want the drop down to first display "Choose an Organization"  Instead, it is displaying the DataTextField (first item in data set).   Thanks in advance.

    .ASCX Control

    <strong>Organization:</strong><br />
    <telerik:RadComboBox runat="server" ID="OrganizationList" 
    EmptyMessage="Choose an Organization" EnableLoadOnDemand="true"
    HighlightTemplatedItems="true" Width="600px" BackColor="#FFFFCC" 
    DataTextField="Name" DataValueField="ContactId" OnItemsRequested="RadComboBox_LoadOrganizations">
            <ItemTemplate>
                <table style="width: 550px;">
                    <tr>
                        <td><%# DataBinder.Eval(Container.DataItem, "Name") %></td>
                    </tr>
                  
                </table>
            </ItemTemplate>   
    </telerik:RadComboBox>

    .ASCX.CS Code Behind
    protected void RadComboBox_LoadOrganizations(object sender, RadComboBoxItemsRequestedEventArgs e)
    {
        int userID;
        userID = Convert.ToInt32(Server.HtmlEncode(Request.QueryString["UID"]));
        OrgView.ContactLookup[] orglist = orgData.GetAssociatedContactsLookupList(userID);
        OrganizationList.DataSource = orglist;
        OrganizationList.DataBind();
    }

  2. Simon
    Admin
    Simon avatar
    2281 posts

    Posted 17 Aug 2010 Link to this post

    Hello Karl Rohrbach,

    Currently the empty message shows only if the RadComboBox is writable and in your case it is read-only. Luckily you can easily resolve this if you:
    • Set the AllowCustomText property to true.
    • Handle the client-side Load event in this way:
      function onLoad(sender) {
          var input = sender.get_inputDomElement();
          input.readOnly = "readonly";
          input.parentNode.parentNode.className = "rcbReadOnly";
      }

    Best wishes,
    Simon
    the Telerik team
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
  3. Ian
    Ian avatar
    3 posts
    Member since:
    Aug 2010

    Posted 25 Aug 2010 Link to this post

    Hello,

    I am also experiencing the same issue where I want to display an EmptyMessage but instead the first item is being selected.  when I run this I get an error that "Object doesn't support this property or method" which I suspect is coming from the .readOnly or attaching to the wrong Client-Side Load event.

    Can you offer any advice with the code samples provided?

    Thanks!

    <telerik:RadComboBox ID="cboAccountLists" runat="server" Width="300px" AllowCustomText="true" EmptyMessage="Select List" HighlightTemplatedItems="true" DataValueField="Value" DataTextField="Text">
         <ItemTemplate>
              <asp:CheckBox runat="server" ID="chkDdAccountsLists" Checked="false" onclick="onAccountsListsCheckBoxClick(this)"/>
              <asp:Label runat="server" ID="lblDdAccountLists" AssociatedControlID="chkDdAccountsLists" Text='<%# Eval("Text") %>'></asp:Label>
         </ItemTemplate>
    </telerik:RadComboBox>

    function onLoad(sender) {
        var input = sender.get_inputDomElement();
        input.readOnly = "readonly";
        input.parentNode.parentNode.className = "rcbReadOnly";
    }
  4. Simon
    Admin
    Simon avatar
    2281 posts

    Posted 26 Aug 2010 Link to this post

    Hi Ian,

    You can attach the client-side Load event by setting the OnClientLoad property of the RadComboBox to the name of the handler function, e.g. OnClientLoad="onLoad".

    I hope this helps.

    Sincerely yours,
    Simon
    the Telerik team
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
  5. jojo
    jojo avatar
    5 posts
    Member since:
    Aug 2010

    Posted 08 Aug 2012 Link to this post

    I can implement your suggested solution, but when I do so, it appears to disable the entire combobox. Do you have a solution that allows us to set the text, not have it editable, but still actually use the combobox?
  6. Helen
    Admin
    Helen avatar
    1052 posts

    Posted 08 Aug 2012 Link to this post

    Hello Joanne,

    What is the exact behavior you want to achieve?
    The AllowCustomText property controls whether you can enter custom text or not.


    Regards,
    Helen
    the Telerik team
    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 their blog feed now.
  7. jojo
    jojo avatar
    5 posts
    Member since:
    Aug 2010

    Posted 08 Aug 2012 Link to this post

    Thanks for your reply Helen, but I'm not sure what other information you require.

    My requirement is the same as described in the previous posts:

    I have a combobox with checkboxes in the template. I wish to be able to display some text in this box e.g. Please select...
    However, I don't want:
     - users to be able to type anything in here as it does not make any sense to do so.
     - Most importantly I do not want it to display the text of just the first selected checkbox, as this could be misleading to users.

    Does that help clarify the issue?
  8. Ivana
    Admin
    Ivana avatar
    657 posts

    Posted 09 Aug 2012 Link to this post

    Hi Joanne,

    The built-in CheckBox functionality provides the exact behavior that you need in your application. The following definition of RadComboBox shows the empty message and it does not allow typing in the input area:
    <telerik:RadComboBox ID="RadComboBox1" runat="server" CheckBoxes="true" EmptyMessage="--Please make a selection--">
        <Items>
            <telerik:RadComboBoxItem Text="item1" />
            <telerik:RadComboBoxItem Text="item2" />
            <telerik:RadComboBoxItem Text="item3" />
        </Items>
    </telerik:RadComboBox>

    I hope this will help.

    Regards,
    Ivana
    the Telerik team
    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 their blog feed now.
  9. jojo
    jojo avatar
    5 posts
    Member since:
    Aug 2010

    Posted 09 Aug 2012 Link to this post

    This does not show textboxes or EmptyMessage in the version we are using (2010.2.826.35)
  10. Ivana
    Admin
    Ivana avatar
    657 posts

    Posted 14 Aug 2012 Link to this post

    Hello Joanne,

    The following should act just like the EmptyMessage property of the RadComboBox in the latest version:
    function pageLoad() {
        var combo = $find("RadComboBox1");
        combo.get_inputDomElement().value = "-- please make a selection --";
    }
    <telerik:RadComboBox ID="RadComboBox1" runat="server">
        <ItemTemplate>
            <input type="checkbox" runat="server"/>
        </ItemTemplate>
        <Items>
            <telerik:RadComboBoxItem Text="item1" />
            <telerik:RadComboBoxItem Text="item2" />
            <telerik:RadComboBoxItem Text="item3" />
        </Items>
    </telerik:RadComboBox>

    Regards,
    Ivana
    the Telerik team
    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 their blog feed now.
Back to Top