This is a migrated thread and some comments may be shown as answers.
RadComboBox LoadOnDemand unable to handle returning zero records
12 Answers 124 Views
This is a migrated thread and some comments may be shown as answers.
Micah Toland
Top achievements
Rank 1
Micah Toland asked on 24 Jun 2010, 07:16 AM

I’m using a web service to feed the search as you type combo box on my page.  If the search returns 0 results I get the following error:

 

Microsoft Jscript runtime error: ‘Items’ is null or not an object

 

It works fine if results are returned.  Below is the code for the RadComboBox and below that is the web service method I’m using.  Any assistance would be greatly appreciated.

 

Experienced this problem with both 2010 Q1 and now Q2 Beta.

 

RadComboBox Snippet:

<telerik:RadComboBox ID="rcmbClients" runat="server" EnableLoadOnDemand="true"
    ShowMoreResultsBox="true" EnableVirtualScrolling="true"
    TabIndex="1" EnableItemCaching="true" EnableViewState="false" EmptyMessage="-- enter text --"
    NoWrap="true" ShowWhileLoading="false"
    OnSelectedIndexChanged="rcmbClients_SelectedIndexChanged"
    AutoPostBack="true" Width="500" WebServiceSettings-Method="GetFilteredClients"
    Filter="Contains" ItemRequestTimeout="300" WebServiceSettings-Path="~/RadService.svc"
    AllowCustomText="true">
</telerik:RadComboBox>  

 

Web Service Snippet:

[ServiceContract(Namespace = "")]
[AspNetCompatibilityRequirements(RequirementsMode = AspNetCompatibilityRequirementsMode.Allowed)]
public class RadService
{
  [OperationContract]
  public RadComboBoxData GetFilteredClients(RadComboBoxContext context)
  {
      try
      {
             
         RadComboBoxData result = new RadComboBoxData();
         ClientBL clientBL = new ClientBL();
         IList<ShortClient> clients = clientBL.GetFilteredShortClients(context.Text.Replace("%""[%]").Replace("&squote""[']"));
         IEnumerable<RadComboBoxItemData> allDataItems = from client in clients
                                                         select new RadComboBoxItemData()
                                                         {
                                                             Text = client.DisplayName,
                                                             Value = client.ID.ToString()
                                                         };
         int numberOfItems = context.NumberOfItems;
         IEnumerable<RadComboBoxItemData> pageOfDataItems = allDataItems.Skip(numberOfItems).Take(500);
         result.Items = pageOfDataItems.ToArray();
         int endOffSet = numberOfItems + pageOfDataItems.Count();
         int totalCount = allDataItems.Count();
         if (endOffSet == totalCount)
             result.EndOfItems = false;
         result.Message = String.Format("Items <b>1</b>-<b>{0}</b> out of <b>{1}</b>", endOffSet, totalCount);
         return result;
     }
     catch (Exception ex)
     {
         string target = context.Text;
         LogManager logManager = new LogManager();
         logManager.Log(TraceEventType.Error, "Search Criteria Submitted By User: \"" + context.Text + "\""  + Environment.NewLine + ex.Message.ToString());
         throw;
     }
}

12 Answers, 1 is accepted

Sort by
0
Simon
Telerik team
answered on 24 Jun 2010, 01:24 PM
Hello Micah Toland,

We are aware of this issue and will fix in the future versions of RadComboBox. Thank you for your involvement.

Greetings,
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
Micah Toland
Top achievements
Rank 1
answered on 24 Jun 2010, 03:58 PM
It blowing up when a user enters criteria that returns zero results is such a fundamental issue we have to reconsider using the control at all.  Is there an estimated time for release of the fix?
0
Simon
Telerik team
answered on 28 Jun 2010, 12:45 PM
Hello Micah Toland,

You are perfectly right - this is a fundamental issue. We will fix it this during this and the next week.

Regards,
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
B
Top achievements
Rank 1
answered on 24 Jul 2010, 03:41 PM
I just downloaded an eval version of your 2010 Q2 Asp.Net Controls.  I get the same error as above using the RadCombobox with a WebService.  Has this not been fixed?
0
Simon
Telerik team
answered on 25 Jul 2010, 12:46 PM
Hi B,

We actually fixed the issue.

Can you please make sure that you have properly upgraded to the new version, i.e. no references to Telerik.Web.UI are cached?

If the version is correct, please describe in more detail the exact setup that is triggering the error as it may be a different one.

All the best,
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
B
Top achievements
Rank 1
answered on 25 Jul 2010, 02:22 PM

Yes, it is strange, the control works perfectly until i type a value (last name) that returns 0 items.  then i get the following error:

"Microsoft JScript runtime error: 'Items' is null or not an object" (Break/Continue/Ignore)

More details:
VS 2010
Project References: C:\Program Files (x86)\Telerik\RadControls for ASP.NET AJAX Q2 2010\Bin40\Telerik.Web.UI.dll (version 2010.2.713.40)
Cleared debug / release / bin folder and rebuilt project.  that didn't help.

Sample Code:

web page:

  <telerik:RadScriptManager ID="RadScriptManager1" runat="server">
    </telerik:RadScriptManager>
    <div>
        <telerik:RadComboBox ID="RadComboBox1" runat="server" EnableLoadOnDemand="true" ShowMoreResultsBox="true"
            MarkFirstMatch="true" EmptyMessage="Type here...">
            <WebServiceSettings Method="GetClientList" Path="Services/ListService.svc" />
        </telerik:RadComboBox>
        <asp:Button ID="Button1" runat="server" OnClick="Button1_Click" Text="Button" />
        <asp:Label ID="Label1" runat="server" Text="Label"></asp:Label><br />
        <select id="test">
        </select>
    </div>


















 

 Web Service:

  public class ListItem
        {
            public int ID { getset; }
            public string Text { getset; }
        }

  [OperationContract]
        public Telerik.Web.UI.RadComboBoxData GetClientList(Telerik.Web.UI.RadComboBoxContext context)
        {
            RadComboBoxData result = new RadComboBoxData()
            Model.DbContext db = new Model.DbContext();

            var allItems = (from d in db.Clients

                            orderby d.LastName
                            select new ListItem
                            {
                                ID = d.DirID,
                                Text = d.LastName
                            });

            string filter = context.Text;
            if (!String.IsNullOrEmpty(filter))
            {
                allItems = allItems.Where(d => d.Text.StartsWith(filter));
            }

            // perform the paging
            int numberOfItems = context.NumberOfItems;
            var items = allItems.Skip(numberOfItems).Take(10);

            // execute database query
            List<ListItem> tmpItems = items.ToList();
            result.Items = tmpItems.Select(d => new RadComboBoxItemData() { Text = d.Text, Value = d.ID.ToString() }).ToArray();

            int endOffset = numberOfItems + items.Count();
            int totalCount = allItems.Count();
            if (endOffset == totalCount) result.EndOfItems = true;

            //Initialize the status message
            result.Message = String.Format("Items <b>1</b>-<b>{0}</b> out of <b>{1}</b>", endOffset, totalCount);

            return result;
        }
0
B
Top achievements
Rank 1
answered on 25 Jul 2010, 03:41 PM
Okay,

-i uninstalled the RadControls from my machine,
-i cleared my browser cache,
-i rebooted. 
-I reinstalled the RadControls from the trial downloads. 
-I deleted the \bin and \obj directories in my project,
-I rebuilt the project. 

...and I still get the error.  Any chance the RadControls Trial install has the old buggy version?
0
Simon
Telerik team
answered on 29 Jul 2010, 02:57 PM
Hello B,

The Trial and Dev versions are exactly the same in terms of functionality.

I just verified the case with the latest version of Telerik.Web.UI and can confirm that it works properly. In this demo, I modified the WCF service to not set the Items property of the RadComboBoxData object and the RadComboBox handled this without an error on the client side.

Can you please open the HTML source of the page and search for '2010.' - this will show the version of Telerik.Web.UI which is actually used on the page?

Kind regards,
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
B
Top achievements
Rank 1
answered on 30 Jul 2010, 06:57 PM

Okay, here's my html page.  Pretty simple...it's got the radcombo and a scriptmanager control.  I did not find a reference to 2010.  I also attached a version screenshot of the telerik.we.ui in my project reference...

<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="WebForm1.aspx.cs" Inherits="CP.Web.WebForm1" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>
</head>
<body>
    <form id="form1" runat="server">
    <div>
        <telerik:RadScriptManager ID="RadScriptManager1" runat="server">
        </telerik:RadScriptManager>
        
         <telerik:RadComboBox ID="RadComboBox1" runat="server" EnableLoadOnDemand="true" ShowMoreResultsBox="true"
            MarkFirstMatch="true" EmptyMessage="Type here...">
            <WebServiceSettings Method="GetClientList" Path="Services/ListService.svc" />
        </telerik:RadComboBox>
        
    </div>
    </form>
</body>
</html>
0
B
Top achievements
Rank 1
answered on 31 Jul 2010, 01:16 AM
I fixed the problem.  I had to clear all references to the HttpHandlers re: Telerik in the web.config...and then re-add them.  Very strange....but it's working now.
0
Anthony Terra
Top achievements
Rank 1
answered on 11 Oct 2010, 09:56 PM
Is there a hot fix for this issue, the idea of having to re-reference all of my telerik controls is not appealing...
0
Simon
Telerik team
answered on 12 Oct 2010, 09:29 AM
Hi Anthony Terra,

The bug is fixed in Q2 2010 (version 2010.2.713) and later. The procedure of re-referencing the Telerik.Web.UI assembly is required only if the assembly has been cached and after upgrading you continue to see the issue. Otherwise updating the assembly is enough.

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
Asked by
Micah Toland
Top achievements
Rank 1
Answers by
Simon
Telerik team
Micah Toland
Top achievements
Rank 1
B
Top achievements
Rank 1
Anthony Terra
Top achievements
Rank 1
Share this question
or