Need Gridview to refresh data

12 posts, 0 answers
  1. martin bertram
    martin bertram avatar
    11 posts
    Member since:
    Oct 2009

    Posted 10 Nov 2010 Link to this post

    I'm writing a multi-user application with WPF and I need the Rad Gridview to maintain fresh data as it may be changed by other users.  I'm using VB.NET and an ADO .NET entity for the business object.  How can this be done?
  2. Maya
    Admin
    Maya avatar
    4062 posts

    Posted 11 Nov 2010 Link to this post

    Hello martin bertram,

    Please provide more details about your requirements and expected behavior. When exactly do you want your data to be refreshed ? Does the user change the whole data source or just some of the values inside the grid ? 

    Greetings,
    Maya
    the Telerik team
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
  3. martin bertram
    martin bertram avatar
    11 posts
    Member since:
    Oct 2009

    Posted 11 Nov 2010 Link to this post

    The values of the data in the grid may be changed by other users in other programs and I need the grid to be able to display the current values and any new records, etc.  as quickly as possible while maintaining performance and without reseting the whole view for the user.  I've tried using gridview.Items.Refresh and it just crashes the application right away. 
  4. martin bertram
    martin bertram avatar
    11 posts
    Member since:
    Oct 2009

    Posted 11 Nov 2010 Link to this post

    OK I fixed the crashing for the refresh.  But the problem is now that I need it to refresh without disrupting the selected item, scroll position, etc. of the grid. 
  5. Pavel Pavlov
    Admin
    Pavel Pavlov avatar
    2039 posts

    Posted 11 Nov 2010 Link to this post

    Hi martin bertram,

    Having in mind you do not want to reset the ItemsSource , here is one possible solution :

    Your ItemsSource ( the collection that RadGridView is bound to ) should contain objects that implement the INotifyPropertyChanged interface.

    When any user changes property in the object , it should properly raise the PropertyChanged event . This way RadGridView will sense the change and update the cell relevant to the changed value .

    Let me know in case you need a sample on this.

    Sincerely yours,
    Pavel Pavlov
    the Telerik team
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
  6. martin bertram
    martin bertram avatar
    11 posts
    Member since:
    Oct 2009

    Posted 11 Nov 2010 Link to this post

    Great.  Yes please provide a sample if you can.  Preferrably in vb.  Thanks
  7. Pavel Pavlov
    Admin
    Pavel Pavlov avatar
    2039 posts

    Posted 17 Nov 2010 Link to this post

    Hi martin bertram,


    Please find the sample attached.  When you run it you will notice there are three  instances of RadGridView.  This is to simulate input form 3 different places ( e.g. 3 users) .

    You can test it the following way:
    Changing the Price value in one of the grids , will reflect immediately in the other grids , without disrupting the scroll or selection state of the other grids.

    The trick is to raise the PropertyChanged event of the source object , when a value has changed by another user.


    *please note  that for the purposes of the sample I have implemented the NotifyPropertyChanged pattern only for the "Price " field.

    All the best,
    Pavel Pavlov
    the Telerik team
    See What's New in RadControls for WPF in Q3 2010 on Tuesday, November 16, 2010 11:00 AM - 12:00 PM EST or 10:00 PM - 11:00 PM EST: Register here>>
  8. Troy Goddu
    Troy Goddu avatar
    11 posts
    Member since:
    Dec 2009

    Posted 17 Nov 2010 Link to this post


    Pavel, I am doing some real time updating of our grids, but I have only used data binding.  My data is constructed within Entity Framework, mostly from a database.  My grids update but seem kind of slow.  Perhaps implementing INotifyPropertyChanged somewhere would help me.  Do you have a C# version of your sample? 

    Sincerely,
    RIchard

  9. Pavel Pavlov
    Admin
    Pavel Pavlov avatar
    2039 posts

    Posted 18 Nov 2010 Link to this post

    Hello Troy Goddu,

    Please find the c# version attached.

    Regards,
    Pavel Pavlov
    the Telerik team
    Browse the videos here>> to help you get started with RadControls for WPF
  10. Troy Goddu
    Troy Goddu avatar
    11 posts
    Member since:
    Dec 2009

    Posted 19 Nov 2010 Link to this post

    Excellent!  Thank you very much, Pavel.

    Sincerely,
    Richard Craven
  11. Mike
    Mike avatar
    11 posts
    Member since:
    Jun 2014

    Posted 13 Jun 2014 Link to this post

    Hi we have the same problem of needing fresh data.  I downloaded the solution, and I see how it works, but isn't this kind of cheating?  All 3 grids in the same instance of the the application run.  Will it still work across users on the same intranet?  For example if User A updates the price on Workstation A, will User B on Workstation B also see that change immediately?
  12. Nick
    Admin
    Nick avatar
    593 posts

    Posted 16 Jun 2014 Link to this post

    Hi Mike,

    The solution that Pavel offered is the common mechanism that is used to notify multiple UIelements that are bound to the same object that there is a change in the source. Nevertheless, this will not work for multiple instances of the same application. The data synchronization that you are trying to achieve is a very complex problem that can be resolved by multiple solutions (Push up notifications, cyclomatic changes updates, etc.)

    Hope this makes sense. 

    Regards,
    Nik
    Telerik
     
    Check out Telerik Analytics, the service which allows developers to discover app usage patterns, analyze user data, log exceptions, solve problems and profile application performance at run time. Watch the videos and start improving your app based on facts, not hunches.
     
Back to Top