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

How do I make KendoUI read my RESTAPI source?

9 Answers 13 Views
Data Source
This is a migrated thread and some comments may be shown as answers.
Christophe
Top achievements
Rank 1
Christophe asked on 19 Mar 2019, 05:21 AM

```json

{
"version": "v1",
"resource": "customer",
"status": "success",
"paginator": {
"count": 25,
"currentPage": 1,
"lastPage": 2,
"perPage": 25,
"total": 50,
"nextPageUrl": "http://oc-scheduler.local/api/scheduler/customers?page=2"
},
"data": [
{
"id": 1,
"erp_number": "67261537",
"company": null,
"name": "Keven Emmerich",
"email": "keith.lakin@adams.com",
"phone": null,
"fax": null,
"address": null,
"postal_code": null,
"city": null,
"country": null,
"unit": null,
"floor": null,
"alternate_phone": null
},
{
"id": 2,
"erp_number": "46316763",
"company": null,
"name": "Guy Predovic",
"email": "ljaskolski@cassin.biz",
"phone": null,
"fax": null,
"address": null,
"postal_code": null,
"city": null,
"country": null,
"unit": null,
"floor": null,
"alternate_phone": null
}

]

}

```

9 Answers, 1 is accepted

Sort by
0
Christophe
Top achievements
Rank 1
answered on 19 Mar 2019, 05:23 AM

it returns me the following error in the console:

 

VM4468:1 Uncaught SyntaxError: Unexpected token :
    at m (index.js:2)
    at Function.globalEval (index.js:2)
    at text script (index.js:2)
    at Ut (index.js:2)
    at k (index.js:2)
    at XMLHttpRequest.<anonymous> (index.js:2)

0
Christophe
Top achievements
Rank 1
answered on 19 Mar 2019, 05:23 AM

it returns me this error

 

VM4468:1 Uncaught SyntaxError: Unexpected token :
    at m (index.js:2)
    at Function.globalEval (index.js:2)
    at text script (index.js:2)
    at Ut (index.js:2)
    at k (index.js:2)
    at XMLHttpRequest.<anonymous> (index.js:2)

0
Christophe
Top achievements
Rank 1
answered on 19 Mar 2019, 05:24 AM

it gives me this error

 

Uncaught SyntaxError: Unexpected token :
    at m (index.js:2)
    at Function.globalEval (index.js:2)
    at text script (index.js:2)
    at Ut (index.js:2)
    at k (index.js:2)
    at XMLHttpRequest.<anonymous> (index.js:2)

0
Christophe
Top achievements
Rank 1
answered on 19 Mar 2019, 05:24 AM
it gives me this error

Uncaught SyntaxError: Unexpected token :
    at m (index.js:2)
    at Function.globalEval (index.js:2)
    at text script (index.js:2)
    at Ut (index.js:2)
    at k (index.js:2)
    at XMLHttpRequest.<anonymous> (index.js:2)
0
Ivan Danchev
Telerik team
answered on 20 Mar 2019, 02:41 PM
Hello Christophe,

You can get data from a remote service with the Kendo UI DataSource. See the Create DataSource for Remote Services section of the documentation, which contains more information on how the DataSource can be configured in such scenarios. For all DataSource configuration options, methods and events refer to the API documentation.

If you are using the DataSource by itself (it is not used by another Kendo UI widget), after configuring it and initializing it, you can call its fetch API method as demonstrated in the example you can find in the  method's documentation. Calling this method will read the data from the remote service.

The DataSource sends jQuery.ajax() requests to the remote endpoint, so if you are able to read the data with a standard jQuery.ajax() request, you should be able to do the same with the Kendo UI DataSource.

Regards,
Ivan Danchev
Progress Telerik
Get quickly onboarded and successful with your Telerik and/or Kendo UI products with the Virtual Classroom free technical training, available to all active customers. Learn More.
0
Christophe
Top achievements
Rank 1
answered on 01 Apr 2019, 05:05 AM

Hi Ivan,

thanks, I read the documentation and I find anywhere stated how to my array of data which is embedded inside my response. The Kendo DS suppose that it will receive the data which is not always the case. In my case, I setup paginator for example. so my response is of type:

 

{

   "current_page":1,

   "data" : [

       { "id":1, "company":" " },

       { "id":2, "company":"fsdf fds" },

   ]

}

 

How do I bind the data into the Kendo Data please?

0
Ivan Danchev
Telerik team
answered on 02 Apr 2019, 02:33 PM
Hello Christophe,

The DataSource sends a request to the service and receives the data. From there on another widget can be used to visualize that data. That being said, could you elaborate more on your scenario:
  1. Does the request to the service fail? (you can check that by handling the error event of the DataSource)
  2. Do you use another widget to display the data received by the DataSource, for example a Grid?
  3. Once the data is received, do you operate with it in any way? If so, how? And at which point does the exception get thrown? 
It would help us get an idea of the scenario and the issue you are experiencing, if you are able to demonstrate the issue you are experiencing in a dojo example or in an runnable isolated sample project.

Regards,
Ivan Danchev
Progress Telerik
Get quickly onboarded and successful with your Telerik and/or Kendo UI products with the Virtual Classroom free technical training, available to all active customers. Learn More.
0
Christophe
Top achievements
Rank 1
answered on 03 Apr 2019, 02:02 AM

Thanks for your message

I am using a simple grid.

to get a sense of the  returned my my REST API, please refer to my previous message, it is in there.

All the API does not return JUST the data array like in your examples, in my there are other embedded data and I change them as it is an external service. My guess is that somewhere there is a way to handle this scenario with KendoUI. Thank you

0
Ivan Danchev
Telerik team
answered on 04 Apr 2019, 02:11 PM
Hello Christophe,

Since you are using a Grid to display the data you can use the dataSource's schema.data option to get the dataItems from the response's "data" field. Here's a dojo example, in which a Grid properly displays your data.

Regards,
Ivan Danchev
Progress Telerik
Get quickly onboarded and successful with your Telerik and/or Kendo UI products with the Virtual Classroom free technical training, available to all active customers. Learn More.
Tags
Data Source
Asked by
Christophe
Top achievements
Rank 1
Answers by
Christophe
Top achievements
Rank 1
Ivan Danchev
Telerik team
Share this question
or