Empty Message

4 posts, 1 answers
  1. Carsten Koster
    Carsten Koster avatar
    25 posts
    Member since:
    Sep 2006

    Posted 01 Jun 2012 Link to this post

    Hey,

    I have searched for quite some time now but did not find a solution. Maybe you can tell me if it's possible to display a message if a radrotator that is filled by a 'load on demand'-webservice responds with zero items?

    The main problem is that the "ItemsRequested"-Event is not fired if the return value of the webservice is an empty array.

    Thank you for your support.
    Regards
    Kris
  2. Slav
    Admin
    Slav avatar
    1356 posts

    Posted 06 Jun 2012 Link to this post

    Hello Carsten,

    The RadRotator has a client-side event OnClientItemsRequestFailed that is fired when Load On Demand is used and the request has failed, which includes your case. Please examine this help article for more detailed description of the event. It also includes an example that demonstrates removing the displayed alert dialog and using its messages in the markup of the page.

    I hope this helps. Feel free to contact us again if you run into more difficulties.

    Regards,
    Slav
    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.
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Carsten Koster
    Carsten Koster avatar
    25 posts
    Member since:
    Sep 2006

    Posted 07 Jun 2012 Link to this post

    Hello Slav,

    thank you for you response.

    I had tested the solution you provided before. It does not work as the event is not thrown if the webservice returns an empty array.

    Please provide me with a working solution. (I am not willing to throw an exception to signal an empty array in the webservice as it's plain wrong :-)

    Regards,
    Kris
  5. Answer
    Slav
    Admin
    Slav avatar
    1356 posts

    Posted 11 Jun 2012 Link to this post

    Hi Carsten,

    Indeed, the OnClientItemsRequestFailed is not fired when the web service returns an empty array. You can handle the event OnClientItemsRequesting as shown in the following sample code to check if there are loaded items:
    <script type="text/javascript">
        var OnServiceLoaderSuccessDelegate;
        function OnClientItemsRequesting(sender, args) { // OnClientItemsRequesting event handler
            OnServiceLoaderSuccessDelegate = Function.createCallback(OnServiceLoaderSuccess, sender);
            sender._webServiceLoader.add_loadingSuccess(OnServiceLoaderSuccessDelegate);
        }
     
        function OnServiceLoaderSuccess(loader, args, rotator) {
            loader.get_events().removeHandler("loadingSuccess", OnServiceLoaderSuccessDelegate);
            if (rotator.get_items().length == 0) {
                alert("No items are loaded!");
            }
        }
    </script>

    Feel free to contact us again if you run into more difficulties.

    Kind regards,
    Slav
    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.
Back to Top