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

Basic Usage

1 Answer 124 Views
ClientDataSource
This is a migrated thread and some comments may be shown as answers.
SANJAY
Top achievements
Rank 1
SANJAY asked on 23 Jun 2014, 03:44 AM
I have a webapi running on http://services.thetaskmate.in/api/ImageGallery/aa

When I run the api in webbrowser I get desired result
I have checked the api in Fiddler and I get json data

When I execute your example page
      <telerik:RadImageGallery runat="server" ID="RadImageGallery1" Height="600px" Width="800px"
        ClientDataSourceID="RadClientDataSource1"
        DataImageField="ImageUrl" DataThumbnailField="ThumbUrl" DataTitleField="Title">
        <ClientSettings>
            <AnimationSettings>
                <NextImagesAnimation Type="VerticalSlide" />
                <PrevImagesAnimation Type="VerticalSlide" />
            </AnimationSettings>
        </ClientSettings>
    </telerik:RadImageGallery>

    <telerik:RadClientDataSource runat="server" ID="RadClientDataSource1"  >
        <DataSource>
            <WebServiceDataSourceSettings BaseUrl ="http://services.thetaskmate.in/api/ImageGallery/aa" >
                <Select Url="http://services.thetaskmate.in/api/ImageGallery/aa"  RequestType="Get"  DataType="JSON"   />
            </WebServiceDataSourceSettings>
        </DataSource>
        <Schema DataName="D" >
             <Model>
                <telerik:ClientDataSourceModelField FieldName="ImageUrl" DataType="String" />
                <telerik:ClientDataSourceModelField FieldName="ThumbUrl" DataType="String" />
                <telerik:ClientDataSourceModelField FieldName="Title" DataType="String" />
                 <telerik:ClientDataSourceModelField FieldName="Description" DataType="String" />
            </Model>
        </Schema>
        <ClientEvents  OnRequestFailed="tst"  OnRequestStart="b" OnDataParse="c" />
    </telerik:RadClientDataSource>

<script type="text/javascript">
    function tst(){
        alert("a");
    }
    function b() {
        alert("b");
    }
    function c() {
        alert("data");
    }
</script>

I get a RequestFailed.

1 Answer, 1 is accepted

Sort by
0
Hristo Valyavicharski
Telerik team
answered on 25 Jun 2014, 04:04 PM
Hi Sanjay,

Your settings are incorrect:
<telerik:RadClientDataSource runat="server" ID="RadClientDataSource1">
          <DataSource>
              <WebServiceDataSourceSettings BaseUrl="http://services.thetaskmate.in/api/ImageGallery/">
                  <Select Url="aa" RequestType="Get" DataType="JSON" />
              </WebServiceDataSourceSettings>
          </DataSource>

But at the moment your web api controller blocks cross domain requests.
I'm getting the following error when I call it:

Cross-Origin Request Blocked: The Same Origin Policy disallows reading the remote resource at http://services.thetaskmate.in/api/ImageGallery/aa. This can be fixed by moving the resource to the same domain or enabling CORS.

Regards,
Hristo Valyavicharski
Telerik
 

Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

 
Tags
ClientDataSource
Asked by
SANJAY
Top achievements
Rank 1
Answers by
Hristo Valyavicharski
Telerik team
Share this question
or