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

Reload data from server into dataSource

2 Answers 73 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Manuel
Top achievements
Rank 1
Manuel asked on 12 Mar 2014, 09:08 PM
Hi folks,

first of all thanks for this great product. It's really fun to create apps with Kendo Mobile.

I have a question regarding reloading data into a dataSource.
Let me explain the current situation.
We have a hierarchial date e.g. several manufacturers have several have several car models, each model exist in different types etc.
This sounds perfect for a HierarchicalDataSource, right?
But here comes the point:
Currently the remote backend provides me always just a part of the data. E.g.

1. Show a view with all available manufacturers by calling e.g. http://example.com/manufacturers
2. Now the user can select one manufacturer and will be forwarded to another view where only the models of the currently selected manufacturer will be loaded.
The url is e.g. http://example.com/cars/1 to fetch all cars of manufacturer with id 1.
There is a DataSource in the cars view which is created everytime the view is loaded (init event). This is basically ok, but the data is loaded everytime the view is accessed although we already have loaded the data from the server. 

I hope I made myself clear enough.

So is there somehow a way to reload data into a DataSource that already contains data from a remote service? Can the add() method if the DataSource be used for something like this?

Otherwise I may have to discuss with my colleagues if it is possible to restructure the backend.

Regards and thanks for your support!!

2 Answers, 1 is accepted

Sort by
0
Alexander Valchev
Telerik team
answered on 17 Mar 2014, 10:01 AM
Hi Manuel,

In answer to your questions:

So is there somehow a way to reload data into a DataSource that already contains data from a remote service?
The recommended way to reload the DataSource's data from remote service is by using the read method.

Can the add() method if the DataSource be used for something like this?
No, add method is intended to be used for inserting additional records in the DataSource on the client side. If you want to refresh the data from the remote service you should use the read method.

On a side note, for the scenario you described you can use hierarchical dataSource - mobile ListView supports hierarchical data binding:
Last but not least the following part of your description is not clear:
There is a DataSource in the cars view which is created everytime the view is loaded (init event). This is basically ok, but the data is loaded everytime the view is accessed although we already have loaded the data from the server.

The init event fires only once when the view is accessed for first time. Any subsequent navigation to the View should not execute the init event handler unless some additional configuration is set.

Regards,
Alexander Valchev
Telerik
 

DevCraft Q1'14 is here! Watch the online conference to see how this release solves your top-5 .NET challenges. Watch on demand now.

 
0
Manuel
Top achievements
Rank 1
answered on 20 Mar 2014, 08:04 PM
Hi Alexander,

thanks for your reploy.

Your answers fulfilled my thoughts. So there is no way to add new data to an already created dataSource.

Sorry I ment the show event. Every time the view was shown a dataSource was bind to the listview. I realized meanwhile that this is a very bad practice and I'll try to refactor this with the knowledge of your answers.

Thanks again for your infos.

Regards



Tags
General Discussions
Asked by
Manuel
Top achievements
Rank 1
Answers by
Alexander Valchev
Telerik team
Manuel
Top achievements
Rank 1
Share this question
or