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

Reading from a webservice using datasource transport read has an issue

5 Answers 111 Views
Data Source
This is a migrated thread and some comments may be shown as answers.
devApps
Top achievements
Rank 1
devApps asked on 29 Nov 2016, 07:41 AM

I am  trying to read from the following webservice :

http://apis.io/api/apis

Here is the code snippet :

Telerik Dojo Code Snippet

http://dojo.telerik.com/@phcc1t/oSEBa

 

Could you please let me know where is the issue

5 Answers, 1 is accepted

Sort by
0
Alex Hajigeorgieva
Telerik team
answered on 30 Nov 2016, 01:29 PM
Hi,

The issue is with the Kendo UI Data Source configuration, therefore, I moved your post in this forum thread.

Thank you for providing the Dojo snippet, I modified it with the following changes and it is now working as expected:

- dataType of the transport read operation is now JSON

The service returns JSON, so the correct dataType is JSON. 

http://docs.telerik.com/kendo-ui/api/javascript/data/datasource#configuration-transport.read.dataType

- added missing schema data

http://docs.telerik.com/kendo-ui/api/javascript/data/datasource#configuration-schema.data

Looking at the response format - you should be able to configure the Kendo UI Data Source with the schema data property unless you need to make any changes, the call to schema parse is unnecessary. E.g. instead of looping over the response.data,  both instances could have a similar configuration:

var myDataSource2 = new kendo.data.DataSource({
  transport: {
   read:  {
    url: "http://apis.io/api/apis",
    dataType: "json"
   }
  },
  schema: {
   data: "data"
  }
});

- the Kendo UI Data Source data should be an array, not a string (myDataSource1 - "status"):

http://docs.telerik.com/kendo-ui/api/javascript/data/datasource#configuration-data

- the Kendo UI Mobile ListView requires a mobile application and a view so they can run and trigger a read request:

http://docs.telerik.com/kendo-ui/controls/hybrid/application#initialize-the-mobile-view

I have updated the example and you can press "Run" in the below Dojo snippet or go to its FullScreen mode:

http://dojo.telerik.com/ERaNe 

Kind Regards,
Alex Hajigeorgieva
Telerik by Progress
Kendo UI is ready for Visual Studio 2017 RC! Learn more.
0
devApps
Top achievements
Rank 1
answered on 06 Dec 2016, 06:46 AM

Thanks a lot Alex  for the detailed explanation and references.

Really appreciate it.

0
devApps
Top achievements
Rank 1
answered on 07 Dec 2016, 12:31 PM

Is there any way that I can limit the number of items that are displayed in the listview ?

I will read the data from the webservice , but from the result I need to display say only the first two or last two ?

0
devApps
Top achievements
Rank 1
answered on 08 Dec 2016, 07:56 AM

I was to able to limit the data by using the query option

http://docs.telerik.com/kendo-ui/api/javascript/data/datasource#methods-query

But I still I have one more final thing left.

Basically I am using the Barcode plugin to scan a barcode , and the scanned data is added to the Telerik back-end content type , and the content type's data is displayed in a list view.

Scanning and adding to the back-end content type is fine , but the list does not get automatically refreshed with the newly added data.

I have also used the sort option in the query such that the latest added option is at the first page.

Also used datasource read and sync methods after adding the data

Despite this I have to refresh or reload the app to see the newly added item in the list.

Any pointers how can I fix this ?

0
Alex Hajigeorgieva
Telerik team
answered on 09 Dec 2016, 12:50 PM
Hi,

The approach that you have taken with calling the read() method of the Kendo UI Data Source when there have been changes in the backend is correct. If the changes were added through the UI, then you would need to call the add() method and then sync() to sync the changes with the server.

If I understand you correctly, you are inquiring about how to refresh the Kendo UI Hybrid ListView when there are changes on the server. I have created a sample demo with a similar scenario, please feel free to modify it and return the newly generated URL from the address bar:

http://dojo.telerik.com/AjeYo

Alternatively, you may provide a snippet which shows how and when the read() method is called.

Look forward to hearing back from you.
 
Regards,
Alex Hajigeorgieva
Telerik by Progress
Kendo UI is ready for Visual Studio 2017 RC! Learn more.
Tags
Data Source
Asked by
devApps
Top achievements
Rank 1
Answers by
Alex Hajigeorgieva
Telerik team
devApps
Top achievements
Rank 1
Share this question
or