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

Empty Message

3 Answers 91 Views
Rotator
This is a migrated thread and some comments may be shown as answers.
Carsten Koster
Top achievements
Rank 2
Carsten Koster asked on 01 Jun 2012, 12:04 PM
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

3 Answers, 1 is accepted

Sort by
0
Slav
Telerik team
answered on 06 Jun 2012, 06:42 AM
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.
0
Carsten Koster
Top achievements
Rank 2
answered on 07 Jun 2012, 11:25 AM
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
0
Accepted
Slav
Telerik team
answered on 11 Jun 2012, 02:28 PM
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.
Tags
Rotator
Asked by
Carsten Koster
Top achievements
Rank 2
Answers by
Slav
Telerik team
Carsten Koster
Top achievements
Rank 2
Share this question
or