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

Fetch vs. Read

3 Answers 1074 Views
Data Source
This is a migrated thread and some comments may be shown as answers.
Mark
Top achievements
Rank 1
Mark asked on 10 Dec 2013, 11:06 PM
The documentation is not clear on the differences between dataSource.fetch() and dataSource.read().  Can you explain the differences?

3 Answers, 1 is accepted

Sort by
0
Atanas Korchev
Telerik team
answered on 11 Dec 2013, 08:01 AM
Hello Mark,

The difference is subtle. From the documentation:

The read method always makes a request to the remote service.

The fetch method makes a request to the remote service only the first time it is called.

Fetch also accepts a callback which will be called when the operation is complete:

dataSource.fetch(function() {
      var data = this.data();
});

Regards,
Atanas Korchev
Telerik
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
0
Mark
Top achievements
Rank 1
answered on 11 Dec 2013, 05:10 PM
Thanks... can you help clarify what use cases are best suited for call vs. fetch? 
0
Atanas Korchev
Telerik team
answered on 12 Dec 2013, 07:42 AM
Hi Mark,

Sure. The read method is used in cases when you want latest data from the server side. On the other hand fetch is used to initially populate the data source. Any subsequent calls return the initial data. 

Regards,
Atanas Korchev
Telerik
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
Tags
Data Source
Asked by
Mark
Top achievements
Rank 1
Answers by
Atanas Korchev
Telerik team
Mark
Top achievements
Rank 1
Share this question
or