WebServiceSettings delay issue / handling of requests in order

4 posts, 0 answers
  1. Steve
    Steve avatar
    7 posts
    Member since:
    Jun 2012

    Posted 14 Nov 2013 Link to this post

    I've noticed the behaviour, for example, of a RadAutoCompleteBox when using WebServiceSettings, that occasionally the responses from the server do not return in the same order they were requested by the client, which makes for confusing the user as entries displayed in the drop-down do not always make sense according to what has been typed.

    This raises two questions:

    1. Is there a delay property on RadAutoCompleteBox/RadSearchBox etc to delay the client request by n milliseconds until the user has stopped typing, instead of firing back several requests as the user types something?
    2. Can the RadAutoCompleteBox/RadSearchBox etc (e.g. via time-stamping client requests to the server or other way) always ensure that responses from the server are ignored unless the response was the last one to be made?

    Hope this makes sense!
  2. Nencho
    Admin
    Nencho avatar
    1457 posts

    Posted 19 Nov 2013 Link to this post

    Hello Steve,

    You could use the _requestDelay method of the RadAutoCompleBox, in order to achieve the desired functionality. Please consider using the OnClientLoad client-side event of the control in the following manner:

    function OnClientLoad(sender) {
               sender._requestDelay = 3000;
           }

    Regards,
    Nencho
    Telerik
    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 the blog feed now.
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Steve
    Steve avatar
    7 posts
    Member since:
    Jun 2012

    Posted 19 Nov 2013 Link to this post

    This seems to have no effect. I am using Telerik.Web.UI.dll 2013.2.717.40 

    The code below does not produce any delay in the client request, the client function onClientPickerRequesting is fired immediately once there is a key press in the RadAutoCompleteBox. The client function onClientLoad is called OK and there is no error thrown. 



    <telerik:RadAutoCompleteBox ID="RadAutoCompleteBox1" Runat="server"  OnClientLoad="onClientLoad" OnClientRequesting="onClientRequesting" >
        <ClientDropDownItemTemplate>
            #= Text#
        </ClientDropDownItemTemplate>
        <WebServiceSettings Path="~/Service.asmx"  Method="GetPickerResults" ></WebServiceSettings>
    </telerik:RadAutoCompleteBox>


    function onClientLoad(sender) {
    sender._requestDelay = 3000;
    alert("onClientLoad called OK.");
    }
    function onClientRequesting(sender, args) {
      alert("Requesting....");
    }
  5. Nencho
    Admin
    Nencho avatar
    1457 posts

    Posted 22 Nov 2013 Link to this post

    Hello Steve,

    The suggested property was not yet introduced in the version that you are using. Therefore, I would suggest you to overwrite the function responsible for the ClientRequesting. Please consider the following implementation, with just configuring the timeout:
    <script type="text/javascript">
            Telerik.Web.UI.RadAutoCompleteBox.prototype.query = function (searchString) {
                var me = this;
                searchString = searchString || this.get_searchString();
                if (this._requestInProgress)
                    clearTimeout(this._requestInProgress);
     
                if (!searchString) {
                    this.clear();
                } else {
                    this._requestInProgress = setTimeout(function () {
                        if (me.get_webServiceSettings())
                            me._doLoadOnDemandFromWebService(searchString);
                        else if (me.get_bindingMode() === Telerik.Web.UI.RadAutoCompleteBinding.OData)
                            me._doLoadOnDemandUsingOData(searchString);
                        else
                            me._doLoadOnDemand(searchString);
                    }, 2000);
                }
            }
        </script>


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