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

How to refresh an item in a datasource with server data?

8 Answers 398 Views
Data Source
This is a migrated thread and some comments may be shown as answers.
Jaap
Top achievements
Rank 2
Jaap asked on 13 Feb 2012, 08:49 AM
Hello,

I have a datasource filled with data. And now I want to refresh a data-item because I know it has changed at the server. How can I do that without reloading the complete datasource?

Thanks, Jaap

8 Answers, 1 is accepted

Sort by
0
Rosen
Telerik team
answered on 15 Feb 2012, 10:50 AM
Hi Jaap,

I'm afraid that refreshing only single DataSource item through ajax is not currently possible.

Regards,
Rosen
the Telerik team
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
0
David
Top achievements
Rank 1
answered on 15 Feb 2012, 10:59 AM
Jaap,

I think you should be looking at how you update the data on the server; if you use the dataSource methods to create or update objects on the server, the dataSource item will automatically have updated, and your bound widgets will be showing updated information.

I guess Rosen can conform this.
0
Jaap
Top achievements
Rank 2
answered on 15 Feb 2012, 11:52 AM
Hi Rosen and David,

Yes I am aware of the fact that when you sync with the datasource the server can return updated objects. That's fine.

But my setup is as follows:
I have a datasource which represents a table on the server, but only a small number of columns of the table (e.g. 5 out of 20).
I use this datasource to display a list of data in a grid widget (will use the upcoming listview widget in future). When I select a row I take the id and open a modal window which uses a second datasource which will retrieve that one object from the server, but with all columns (20). After the data is saved throught that second datasource, I want to update the first datasource. Of course I can do a datasource.refresh(), but that will read the complete list. Would be more efficient in this case if I could do a kind of sync while there is not actually a change.

Regards, Jaap
0
David
Top achievements
Rank 1
answered on 15 Feb 2012, 12:30 PM
Makes sense to me.  Pulling all 20 fields might indeed not be such a great performance suggestion, so perhaps it would indeed be nice if Tekerik could open up the data, so we can update it through a new method as well :)

Makes perfect sense, and now that I think about it, I absolutely second that feature request, as I just realised that we get in all data as well even though we only display a limited set in the grid :)
0
Jaap
Top achievements
Rank 2
answered on 23 Feb 2012, 07:36 AM
0
Simon
Top achievements
Rank 1
answered on 16 May 2014, 04:21 PM
The user voice request has been flagged as completed but the example provided as a solution is for local data...

Can you help us to find a way to handle this for virtual remote data?
0
Simon
Top achievements
Rank 1
answered on 16 May 2014, 05:15 PM
The more I think of it, the more I think this wasn't solved correctly.

The request was closed by providing some kind of workaround example using local data and the transport.update function but the request was clearly for a solution to refresh the data from the server.

The solution provided involve some modifications on the client and server side in order to trick the server about an update (that isn't really an update). Indeed, you'll have to find a way to tell the server that sometime, an update call is suppose to update the record but in other situation, it's only to get a refresh of a given record.

An other issue with this solution is the fact that you might not want to sync the entire dataSource just to refresh one record (Especially when.there's not distinction between the dataItems that should be updated vs the dataItems that should be refreshed.

OData dataSource could easily get the specific record to update by sending the right Skip / Take parameter to the server.

If this can't be done with an OData request, I think that kind of operation should have a function of it's own ( transport.refresh() ) to avoid any confusion about the purpose of the existing create / update / destroy methods.






0
Andrew
Top achievements
Rank 1
answered on 16 May 2014, 07:39 PM
I had a similar need and came up with an implementation that has worked for us so far. I wrote a blog post about it:
http://newyankeecodeshop.tumblr.com/post/85936160493/refreshing-a-single-item-in-a-kendo-datasource

The full source to the custom DataSource is available on github:
https://github.com/wingspan/wingspan-data/blob/master/js/data/DataStore.js

Hope this helps!
Tags
Data Source
Asked by
Jaap
Top achievements
Rank 2
Answers by
Rosen
Telerik team
David
Top achievements
Rank 1
Jaap
Top achievements
Rank 2
Simon
Top achievements
Rank 1
Andrew
Top achievements
Rank 1
Share this question
or