RadCombobox ItemsRequested server event doesn't get fired

8 posts, 0 answers
  1. Kathy Yu
    Kathy Yu avatar
    4 posts
    Member since:
    Apr 2006

    Posted 17 Sep 2010 Link to this post

    I have a scenario with multiple RadComboBoxes that don’t seem to fire the Itemsrequested server event  prior to receiving the response from the previous callback.  Here is a page that I wrote to show the problem. When the normal ASP.NET drop down changes indexes, it will make a callback that has a 5 seconds delay in it. If you press the drop down button for either of the RadComboBoxes during this time, it will display loading but never return. You have to click out of the combo box and then back in it to get the items to load.

     

    RadComboBox 1 also has an onblur that calls an AJAX callback to a 5 second delay. If you try to drop down RadComboBox 2 during this delay, it will just show loading and not update.

     

    Do you have any suggestion as to what might be causing this and how to get around it? Ideally the combo boxes will be able to either load during the callback or queue the request so that it will start when the previous callback is complete.


     

    <%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %>
      
    <%@ Register Assembly="Telerik.Web.UI" Namespace="Telerik.Web.UI" TagPrefix="telerik" %>
      
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <head id="Head1" runat="server">
        <title></title>
        <style type="text/css">
            .RadComboBoxDropDown .rcbItem, 
            .RadComboBoxDropDown .rcbHovered, 
            .RadComboBoxDropDown .rcbDisabled, 
            .RadComboBoxDropDown .rcbLoading
            {
                margin: 0 1px;
                padding: 2px 6px;
                white-space: pre;
            }
        </style>
    </head>
    <body>
        <form id="form1" runat="server">
        <asp:ScriptManager ID="ScriptManager1" runat="server" />
        <div>
        <asp:Label ID="lblDDL" Text="Drop Down 1" style="float:left;" runat="server"></asp:Label>
        <asp:DropDownList ID="DDLTest1" runat="server" style="float:left;" AutoPostBack="true" OnSelectedIndexChanged="DDLTest1_SelectedIndexChanged" >
            <asp:ListItem Text="apple" >
            </asp:ListItem>
            <asp:ListItem Text="orange" />
        </asp:DropDownList>
        <br />
        <br />
            <asp:Label ID="lblrcb1" Text="RadComboBox 1" runat="server" style="float:left;" />
            <telerik:RadComboBox ID="RadComboBox1" OnItemsRequested="RadComboBox1_ItemsRequested" style="float:left;" EnableLoadOnDemand="true" OnClientBlur="function(){$find('PageAjaxManager').ajaxRequest('RadComboBox1');}" EnableAjaxSkinRendering="true" ItemRequestTimeout="1000" runat="server">
            </telerik:RadComboBox>
            <br />
            <br />
            <br />
            <br />
            <br />
            <br />
            <br />
            <br />
            <br />
            <br />
            <br />
            <br />
            <br />
            <br />
            <br />
            <br />
            <asp:Label ID="lblrcb2" Text="RadComboBox 2" runat="server" style="float:left;" />
            <telerik:RadComboBox ID="RadComboBox2" OnItemsRequested="RadComboBox2_ItemsRequested" style="float:left;" EnableLoadOnDemand="true" EnableAjaxSkinRendering="true" ItemRequestTimeout="1000" runat="server">
            </telerik:RadComboBox>
        </div>   
        <telerik:RadAjaxManager ID="PageAjaxManager" runat="server" RequestQueueSize="5" >
        <AjaxSettings>
            <telerik:AjaxSetting AjaxControlID ="DDLTest1" >
                <UpdatedControls>
                    <telerik:AjaxUpdatedControl ControlID="DDLTest1" />
                </UpdatedControls>
            </telerik:AjaxSetting>
        </AjaxSettings>
        </telerik:RadAjaxManager>
        </form>
    </body>
      
    </html>
    using System;
    using System.Data;
    using System.Configuration;
    using System.Web;
    using System.Web.Security;
    using System.Web.UI;
    using System.Web.UI.WebControls;
    using System.Web.UI.WebControls.WebParts;
    using System.Web.UI.HtmlControls;
    using System.Data.OleDb;
    using Telerik.Web.UI;
    using System.Threading;
      
    public partial class _Default : System.Web.UI.Page 
    {
        protected void Page_Load(object sender, EventArgs e)
        {
        }
      
        protected void RadComboBox1_ItemsRequested(object o, RadComboBoxItemsRequestedEventArgs e)
        {
            DataTable dataTable = new DataTable();
            dataTable.Columns.Add(new DataColumn("ID", typeof(string)));
            dataTable.Columns.Add(new DataColumn("Name", typeof(string)));
      
            DataRow dr = dataTable.NewRow();
            dr["ID"] = "1";
            dr["Name"] = Server.HtmlEncode("Name 1         2           3");
            dataTable.Rows.Add(dr);
      
            DataRow dr2 = dataTable.NewRow();
            dr2["ID"] = "2";
            dr2["Name"] = "Name 2    4";
            dataTable.Rows.Add(dr2);
      
            DataRow dr3 = dataTable.NewRow();
            dr3["ID"] = "3";
            dr3["Name"] = "1  Name 3";
            dataTable.Rows.Add(dr3);
      
            if (o is RadComboBox)
            {
      
                (o as RadComboBox).DataSource = dataTable;
                (o as RadComboBox).DataTextField = "Name";
                (o as RadComboBox).DataValueField = "ID";
                (o as RadComboBox).DataBind();
            }
        }
      
      
      
        protected void RadComboBox2_ItemsRequested(object o, RadComboBoxItemsRequestedEventArgs e)
        {
            DataTable dataTable = new DataTable();
            dataTable.Columns.Add(new DataColumn("ID", typeof(string)));
            dataTable.Columns.Add(new DataColumn("Name", typeof(string)));
      
            DataRow dr = dataTable.NewRow();
            dr["ID"] = "1";
            dr["Name"] = Server.HtmlEncode("Name 1         2           3");
            dataTable.Rows.Add(dr);
      
            DataRow dr2 = dataTable.NewRow();
            dr2["ID"] = "2";
            dr2["Name"] = "Name 2    4";
            dataTable.Rows.Add(dr2);
      
            DataRow dr3 = dataTable.NewRow();
            dr3["ID"] = "3";
            dr3["Name"] = "1  Name 3";
            dataTable.Rows.Add(dr3);
      
            if (o is RadComboBox)
            {
      
                (o as RadComboBox).DataSource = dataTable;
                (o as RadComboBox).DataTextField = "Name";
                (o as RadComboBox).DataValueField = "ID";
                (o as RadComboBox).DataBind();
            }
        }
      
        protected override void RaisePostBackEvent(IPostBackEventHandler sourceControl, string eventArgument)
        {
            base.RaisePostBackEvent(sourceControl, eventArgument);
      
            if (sourceControl is RadComboBox || eventArgument == RadComboBox1.ClientID)
            {
                Thread.Sleep(5000);
            }
        }
      
        protected void DDLTest1_SelectedIndexChanged(object sender, EventArgs e)
        {
            Thread.Sleep(5000);
        }
      
    }

     

     

  2. Simon
    Admin
    Simon avatar
    2281 posts

    Posted 23 Sep 2010 Link to this post

    Hi Kathy Yu,

    This happens because the two ajax callbacks happen at the same time. To be more precise the callback RadComboBox initiates happens during an ajax postback so it does not get processed.

    Since it is a different type of callback and is initiated by RCB and not by the RadAjaxManager it cannot be queued up via the RAM's queuing mechanism.

    Perhaps a better way to resolve this would be to disable the RCB(s) during an ajax postback and enable them after it ends. You can use the client-side RequestStart and ResponseEnd events of RAM to do this.

    I hope this is useful.

    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
  3. Kathy Yu
    Kathy Yu avatar
    4 posts
    Member since:
    Apr 2006

    Posted 24 Sep 2010 Link to this post

    Hello Simon,

     

    Thank you for your help with this, but disabling all of the RadComboBox controls on a page during another callback isn’t an acceptable solution. It would cause confusion for our users when certain controls would become disabled for a short period of time. Only after my company recently had switched from the classic ASP.NET controls to the new ASP.NET Ajax controls did we start to see this problem. Is it possible to get the RadComboBoxes to work on the same kind of callbacks as the RadAjaxManager so that they can be queued?
  4. Simon
    Admin
    Simon avatar
    2281 posts

    Posted 29 Sep 2010 Link to this post

    Hello Kathy Yu,

    The classic version of were not based on the ASP.NET AJAX framework and their callback requests were processed in a different way.

    However the controls based on the framework operate in two mutually exclusive ways. You can modify your RadComboBox to not use the ItemsRequested event handler (EnableLoadOnDemand=False). The alternative approach is to use RadAjaxManager in a way you already have implemented for the Blur event. Now you can handle the DropDownOpening event in the same way and only initiate the ajax request if the RadComboBox is empty. Then in the server-side AjaxRequest event handler, based on the RadComboBox ID populate the respective control with data.

    If you have additional questions regarding the implementation of this approach, please let me know.

    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
  5. Kathy Yu
    Kathy Yu avatar
    4 posts
    Member since:
    Apr 2006

    Posted 29 Sep 2010 Link to this post

    Hello Simon,

    Thank you for your response! It seems that none of these solutions would work for my situation. The example I gave was a simplified version of what my company uses. In our actual use, the combo boxes can have thousands of records associated with them. So we have to use load on demand feature to reduce the number that has to originally be loaded on the page.

    The second solution doesn't seems to fit my situation either.We use the Show More Results feature to get additional records for the comboBox. It seems that your suggestion  -- "...handle the DropDownOpening event ... and only initiate the ajax request if the RadComboBox is empty" -- will cause the loss of our "Show More Results" feature. I could be wrong.

    Please advise.

    Kathy
  6. Simon
    Admin
    Simon avatar
    2281 posts

    Posted 30 Sep 2010 Link to this post

    Hello Kathy Yu,

    Another thing you could try is to use a Web Service for Load On Demand. In this way, you will not depend on the ASP.NET AJAX mechanism when loading data for the RadComboBox. This could avoid the initial issue as both processes would interfere with each other.

    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
  7. Kathy Yu
    Kathy Yu avatar
    4 posts
    Member since:
    Apr 2006

    Posted 30 Sep 2010 Link to this post

    Hello Simon

    Once again, thanks for the help with this! I had briefly looked into using a Webmethod for the Load on Demand.  Unfortunately it requires significant re-writing of our existing large-scale Web application. Currently my company is on a tight dead line, therefore re-writing is not an option for us, my company is looking for a simpler fix.

    Please advise.

    Kathy
  8. Simon
    Admin
    Simon avatar
    2281 posts

    Posted 12 Oct 2010 Link to this post

    Hi Kathy Yu,

    Having in mind the nature of the issue there is no simple fix for it.

    The only way to avoid this is to change the type of the request RadComboBox makes to load its Items. One option is to use a Web Service as I stated in my previous response. The other is to us a Page Method.

    Implementing a Page Method is generally simpler than implementing the Web Service and Method. You can reuse most of the code in your ItemsRequested event handler in the new method or directly transform the ItemsRequested method into the new one. Then you need to mark the method with the WebMethod attribute and finally configure the RadComboBox through its Web Service settings.

    Please see this demo showing how to most easily implement a Page Method.

    I hope you find this approach is more acceptable.

    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
Back to Top