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

Need Gridview to refresh data

11 Answers 355 Views
GridView
This is a migrated thread and some comments may be shown as answers.
martin bertram
Top achievements
Rank 1
martin bertram asked on 10 Nov 2010, 10:53 PM
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?

11 Answers, 1 is accepted

Sort by
0
Maya
Telerik team
answered on 11 Nov 2010, 08:24 AM
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
0
martin bertram
Top achievements
Rank 1
answered on 11 Nov 2010, 06:19 PM
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. 
0
martin bertram
Top achievements
Rank 1
answered on 11 Nov 2010, 06:39 PM
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. 
0
Pavel Pavlov
Telerik team
answered on 11 Nov 2010, 06:40 PM
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
0
martin bertram
Top achievements
Rank 1
answered on 11 Nov 2010, 06:43 PM
Great.  Yes please provide a sample if you can.  Preferrably in vb.  Thanks
0
Pavel Pavlov
Telerik team
answered on 17 Nov 2010, 10:51 AM
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>>
0
Troy Goddu
Top achievements
Rank 1
answered on 17 Nov 2010, 04:14 PM

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

0
Pavel Pavlov
Telerik team
answered on 18 Nov 2010, 03:45 PM
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
0
Troy Goddu
Top achievements
Rank 1
answered on 19 Nov 2010, 08:46 PM
Excellent!  Thank you very much, Pavel.

Sincerely,
Richard Craven
0
Mike
Top achievements
Rank 1
answered on 13 Jun 2014, 05:56 PM
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?
0
Nick
Telerik team
answered on 16 Jun 2014, 12:22 PM
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.
 
Tags
GridView
Asked by
martin bertram
Top achievements
Rank 1
Answers by
Maya
Telerik team
martin bertram
Top achievements
Rank 1
Pavel Pavlov
Telerik team
Troy Goddu
Top achievements
Rank 1
Mike
Top achievements
Rank 1
Nick
Telerik team
Share this question
or