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

9 posts, 0 answers
  1. Jaap
    Jaap avatar
    96 posts
    Member since:
    Oct 2012

    Posted 13 Feb 2012 Link to this post

    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
  2. Rosen
    Admin
    Rosen avatar
    3234 posts

    Posted 15 Feb 2012 Link to this post

    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!
  3. Kendo UI is VS 2017 Ready
  4. David
    David avatar
    45 posts
    Member since:
    Feb 2012

    Posted 15 Feb 2012 Link to this post

    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.
  5. Jaap
    Jaap avatar
    96 posts
    Member since:
    Oct 2012

    Posted 15 Feb 2012 Link to this post

    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
  6. David
    David avatar
    45 posts
    Member since:
    Feb 2012

    Posted 15 Feb 2012 Link to this post

    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 :)
  7. Jaap
    Jaap avatar
    96 posts
    Member since:
    Oct 2012
  8. Simon
    Simon avatar
    159 posts
    Member since:
    Sep 2010

    Posted 16 May 2014 Link to this post

    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?
  9. Simon
    Simon avatar
    159 posts
    Member since:
    Sep 2010

    Posted 16 May 2014 Link to this post

    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.






  10. Andrew
    Andrew avatar
    19 posts
    Member since:
    Jan 2013

    Posted 16 May 2014 in reply to Simon Link to this post

    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!
Back to Top
Kendo UI is VS 2017 Ready