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

read() Is not retrieving remote data after setting data

2 Answers 82 Views
Data Source
This is a migrated thread and some comments may be shown as answers.
Grant
Top achievements
Rank 3
Iron
Iron
Iron
Grant asked on 05 Jan 2017, 08:43 AM

Hi, 

Im trying to set a remote datasource's data to an array initially, and then execute the read() method later to retrieve its remote data. But for some reason the read() is not executing the remote call, and the subsequent datasource.data() is just returning the initial array.

Dojo Code: http://dojo.telerik.com/INUWe

Please advise.

Kind Regards,
Grant

2 Answers, 1 is accepted

Sort by
0
Stefan
Telerik team
answered on 06 Jan 2017, 01:47 PM
Hello Grant,

The second time the data method is still returning the array data because it is executed exactly after the read and the new data is still not fetched from the server.

If the second data() method call and console.log are in setTimeout around 1000ms, the new data will be fetched and shown correctly:

http://dojo.telerik.com/imAXo 

Regards,
Stefan
Telerik by Progress
Try our brand new, jQuery-free Angular 2 components built from ground-up which deliver the business app essential building blocks - a grid component, data (charts) and form elements.
0
Grant
Top achievements
Rank 3
Iron
Iron
Iron
answered on 09 Jan 2017, 05:33 AM

Thanks Stefan, 

This make perfect sense, it slipped my mind that the read() returns a promise that must be resolved, instead of an instant response.

Thanks again,
Grant

Tags
Data Source
Asked by
Grant
Top achievements
Rank 3
Iron
Iron
Iron
Answers by
Stefan
Telerik team
Grant
Top achievements
Rank 3
Iron
Iron
Iron
Share this question
or