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

RadGridView not refreshing correctly on dbContext.refresh

5 Answers 773 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Alexander
Top achievements
Rank 1
Alexander asked on 30 Jul 2014, 07:42 AM
I have a strange problem and am looking into it for two days now.

I want to achieve that the radgridview's data is refreshed with the latest data from the database with no noticable delay in UI. So I definately don't want to do a rebind.
The grid's ItemsSource binds to an OberservableCollection(Of poco).
The thing I do is send this ObservableCollection to the dbContext (Telerik DataAccess EntitiesModel class):

dbContext.Refresh(Telerik.OpenAccess.RefreshMode.OverwriteChangesFromStore, toPoco)
After this refresh I fire the PropertyChanged event of the property holding the ObservableCollection.

Here's what happens:
Gridview's UI isn't updated. When I scroll the grid so a gridrow that has been changed is out of view and scroll the changed row back into view, the gridrow does show the right (changed!) data from SQL server.

It looks like the grid isn't getting a signal that the collection has been changed so it doen't update it's UI.

What could i do to refresh the gridview the right way?

Alexander

5 Answers, 1 is accepted

Sort by
0
Dimitrina
Telerik team
answered on 01 Aug 2014, 10:02 AM
Hello Alexander,

You need to raise a CollectionChange notification in order to get the UI reflect the changes from the DataBase.

You can check the approach from the Update item outside RadGridView help article. That way such a notification will be raised just for the item being actually changed. 

The items will also be updated if you invoke a RadGridView.Rebind() or just sort on any column to perform a simple test.

You say that when you scroll the grid so a grid row that has been changed is out of view and scroll the changed row back into view, the gridrow does show the right. This should be as of the UI Virtualization that is enabled by default.

Regards,
Didie
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.
 
0
Alexander
Top achievements
Rank 1
answered on 07 Aug 2014, 02:20 PM
Ok, I ended up doing a rebind of the gridview.

Wichleads me to another problem: I have a DataForm that has to be refreshed too and that has no rebind option.
The only way I found was by saving, clearing and restoring the previously saved DataForm's CurrentItem. 
Is there a better way to do that?

It would be nice if a (DataAccess) dbcontext.Refresh of the poco object would reflect it's changes in the UI automatically...
0
Dimitrina
Telerik team
answered on 08 Aug 2014, 12:18 PM
Hi,

Basically our controls update the UI based on the notifications received from their source (ItemsSource).
If a property of the bound item is changed, then the UI will update once a PropertyChanged notification is received.
In case the collection itself is changed, i.e. an item is added or removed, you should raise a CollectionChanged notification as I explained in my previous post.

Having this in mind, in order to refresh the changes on an existing item, you POCO objects should implement the INotifyPropertyChanged interface.

As a side note, please keep in mind that dbContext.Refresh() will perform a refresh on the existing items only. If you would like to also get the inserted or removed items up to date, then you should invoke the query again.

Regards,
Didie
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.
 
0
William
Top achievements
Rank 1
answered on 07 Mar 2017, 07:14 PM

My RadGridView is NOT refreshing after the underlying data is changed.

These are the statements that have been added:

                this.COResultsGrid.ItemsSource = null;

                this.COResultsGrid.ItemsSource = MyViewModel.Document.COResults;
                this.COResultsGrid.Items.Refresh();

               this.COResultsGrid.Rebind();

 

Routine INotifyPropertyChanged is used for all property sets.

 

0
Dilyan Traykov
Telerik team
answered on 09 Mar 2017, 12:05 PM
Hello William,

Could you please share more details on the exact setup at your end, as, technically, simply calling the Rebind method will update RadGridView's ItemsSource?

Sending over some code snippets of your RadGridView as well as its bound collection would definitely be of help.

Thank you in advance for your cooperation on the matter.

Regards,
Dilyan Traykov
Telerik by Progress
Want to extend the target reach of your WPF applications, leveraging iOS, Android, and UWP? Try UI for Xamarin, a suite of polished and feature-rich components for the Xamarin framework, which allow you to write beautiful native mobile apps using a single shared C# codebase.
Tags
GridView
Asked by
Alexander
Top achievements
Rank 1
Answers by
Dimitrina
Telerik team
Alexander
Top achievements
Rank 1
William
Top achievements
Rank 1
Dilyan Traykov
Telerik team
Share this question
or