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

Missing EmptyMessage and wrong css class after requestItems

10 Answers 200 Views
ComboBox
This is a migrated thread and some comments may be shown as answers.
Tim
Top achievements
Rank 1
Tim asked on 07 Apr 2009, 04:51 PM
I have a RadComboBox that is not databound at the server but is set up with WebServiceSettings to allow it to be loaded from the client.  I am using this to load different items depending on the state of other controls on the page, but do not want load on demand functionality, instead I am calling requestItems() from client-side code when I require the items in the list to change:

<telerik:RadComboBox ID="cboCustomer" runat="server" EmptyMessage="Select a customer" MarkFirstMatch="true" OnClientItemsRequesting="cboCustomer_ItemsRequesting"
    <WebServiceSettings Path="Services/ComboData.asmx" Method="GetCustomers" /> 
</telerik:RadComboBox> 
 
<script type="text/javascript"
    function cboCustomer_ItemsRequesting(sender, eventArgs) { 
        var context = eventArgs.get_context(); 
        context["SelectBy"] = getSelectBy(); 
    } 
</script> 
 

When I then call $find("<%=cboCustomer.ClientID %>").requestItems("", false) the list is populated correctly from my web service, but the empty message disappears.  if I select an item from the list it is displayed with the rcbEmptyMessage css class applied (sometimes multiple times) even though an item is selected.  If I delete the text from the combobox the empty message doesn't reappear.

10 Answers, 1 is accepted

Sort by
0
Tim
Top achievements
Rank 1
answered on 15 Apr 2009, 10:37 AM
A week and still no response.  I'm surprised at this poor level of support.  I have always found Telerik to be very responsive and helpful in the past.
0
Veselin Vasilev
Telerik team
answered on 15 Apr 2009, 11:21 AM
Hello Tim,

This is a known problem and until we fix it I suggest that you use the following workaround:

Subscribe to the OnClientSelectedIndexChanged event and put this code in the handler:

function OnClientSelectedIndexChangedHandler(sender, e) 
    var inputElement = sender.get_inputDomElement(); 
    inputElement.className = inputElement.className.replace("rcbEmptyMessage"""); 
 

Best wishes,
Veselin Vasilev
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
0
Tim
Top achievements
Rank 1
answered on 21 Apr 2009, 11:07 AM
Hi Veselin,

Thanks for getting back to me.

This has fixed part of the problem.

I found that sometimes the rcbEmptyMessage class is on the element multiple times but I can work around this by using
inputElement.className = inputElement.className.replace(/rcbEmptyMessage/g, ""


However, this doesn't resolve the problem that the empty message is no longer displayed after calling requestItems()
.

Do you have any workaround for this?

Thanks,
Tim.
0
Veselin Vasilev
Telerik team
answered on 24 Apr 2009, 08:38 AM
Hello Tim,

I could not reproduce the problem with the requestItems method and the empty message.
Can you please describe the steps that you take?

All the best,
Veselin Vasilev
0
Tim
Top achievements
Rank 1
answered on 28 Apr 2009, 01:57 PM
Page:
<head runat="server"
    <telerik:RadCodeBlock runat="server"
        <script type="text/javascript"
            function refreshNumbersCombo() { 
                $find("<%=cboNumbers.ClientID %>").requestItems("", false); 
            } 
 
            function cboNumbers_ItemsRequesting(sender, eventArgs) { 
                sender.clearSelection(); 
                var context = eventArgs.get_context(); 
                context["Count"] = parseInt($get("txtCount").value); 
            } 
 
            function cboNumbers_SelectedIndexChanged(sender, eventArgs) { 
                var inputElement = sender.get_inputDomElement(); 
                inputElementinputElement.className = inputElement.className.replace(/rcbEmptyMessage/g, ""); 
            } 
 
        </script> 
    </telerik:RadCodeBlock> 
</head> 
<body> 
    <form id="form1" runat="server"
        <asp:ScriptManager ID="scriptManager" runat="server"></asp:ScriptManager> 
 
        <div> 
            <input id="txtCount" type="text" value="1" style="width: 2em;" /> 
            <input id="btnSetCount" type="button" value="Set Count" onclick="refreshNumbersCombo();" /> 
        </div> 
         
        <telerik:RadComboBox ID="cboNumbers" runat="server" MarkFirstMatch="true" EmptyMessage="- Pick a number -" OnClientItemsRequesting="cboNumbers_ItemsRequesting" OnClientSelectedIndexChanged="cboNumbers_SelectedIndexChanged"
            <WebServiceSettings Path="ComboData.asmx" Method="GetNumbers" /> 
        </telerik:RadComboBox> 
    </form> 
</body> 
 

Web service:
    [ScriptService] 
    public class ComboData : System.Web.Services.WebService 
    { 
 
        [WebMethod] 
        public RadComboBoxItemData[] GetNumbers(RadComboBoxContext context) 
        { 
            int count = (int)context["Count"]; 
 
            var items = Enumerable.Range(1, count).Select(i => new RadComboBoxItemData() 
                { 
                    Value = i.ToString(), 
                    Text = i.ToString() 
                }); 
 
            return items.ToArray(); 
        } 
 
    } 
 

Type a number in the text box and click the button to cause the combo box to be repopulated using the web method.  The emptymessage instantly disappears from the combo box and won't reappear, even if you select an item in the combo box and then remove it again.  Hope this helps resolve it...
0
Simon
Telerik team
answered on 01 May 2009, 12:23 PM
Hi Tim,

Thank you for providing the code.

Actually, both issues were caused by the same bug, which we fixed. I updated your Telerik points for the report.

Please download the latest internal build that will be available on the 4th of May to obtain the fix.

Best wishes,
Simon
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
0
Tim
Top achievements
Rank 1
answered on 06 May 2009, 09:01 AM
Thanks for fixing this.  Can you please confirm which build number this is fixed in?  I went to download the internal build today, but neither builds 429 or 430 mention any fixes to the RadComboBox in the change log.
0
Accepted
Simon
Telerik team
answered on 07 May 2009, 08:42 AM
Hi Tim,

Please download Telerik.Web.UI 2009.1.506 from your Client.net account. It includes the fix.

All the best,
Simon
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
0
Tim
Top achievements
Rank 1
answered on 11 May 2009, 11:04 AM
Thanks Simon... I've downloaded this and now all is working fine.
0
Eliza Sahoo
Top achievements
Rank 1
answered on 22 Apr 2010, 01:59 PM
The following code snippet demonstrates how you can add an event handler as well as a CSS class to an element using ScriptManager
Sys.UI.DomEvent  class provides API for attaching handlers to DOM element.
Sys.UI.DomElement class provides API and Properties for manupulating DOM elements.
Tags
ComboBox
Asked by
Tim
Top achievements
Rank 1
Answers by
Tim
Top achievements
Rank 1
Veselin Vasilev
Telerik team
Simon
Telerik team
Eliza Sahoo
Top achievements
Rank 1
Share this question
or