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

RadComboBox not showing EmptyMessage

9 Answers 335 Views
ComboBox
This is a migrated thread and some comments may be shown as answers.
Karl Rohrbach
Top achievements
Rank 1
Karl Rohrbach asked on 17 Aug 2010, 04:47 PM

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();
}

9 Answers, 1 is accepted

Sort by
0
Simon
Telerik team
answered on 17 Aug 2010, 05:01 PM
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
0
Ian
Top achievements
Rank 1
answered on 25 Aug 2010, 10:22 PM
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";
}
0
Simon
Telerik team
answered on 26 Aug 2010, 09:36 AM
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
0
jojo
Top achievements
Rank 1
answered on 08 Aug 2012, 02:54 PM
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?
0
Helen
Telerik team
answered on 08 Aug 2012, 03:27 PM
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.
0
jojo
Top achievements
Rank 1
answered on 08 Aug 2012, 03:32 PM
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?
0
Ivana
Telerik team
answered on 09 Aug 2012, 03:41 PM
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.
0
jojo
Top achievements
Rank 1
answered on 09 Aug 2012, 04:09 PM
This does not show textboxes or EmptyMessage in the version we are using (2010.2.826.35)
0
Ivana
Telerik team
answered on 14 Aug 2012, 10:29 AM
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.
Tags
ComboBox
Asked by
Karl Rohrbach
Top achievements
Rank 1
Answers by
Simon
Telerik team
Ian
Top achievements
Rank 1
jojo
Top achievements
Rank 1
Helen
Telerik team
Ivana
Telerik team
Share this question
or