cells are not updated after underlying object is edited

I have an sfDatagrid in a  wpf-MVVM pattern.

ItemsSource are bound to an ObservableCollection ( ItemsSource="{Binding BooksCollection}",  SelectedItem="{Binding SelectedBook, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}".
The ObservableCollection is populated from an EntityFramework Core DataContext (BooksCollection = _context.Books.Local.ToObservableCollection();).

I face the following problem. If I update programmatically any property of the current record through SelectedItem this change is not propagated to the sfdatagrid and it is not rendered.

I found an example in your knowledge base for elementary databinding according to MVVM, but in your example, it was easy to understand that the DataModel implemented INotifProperty for all propertes of the DataModel. As in my case, data are directly loaded from sql server in code-first implementation, I haven't implemeted the NotifyProperty for the properties of the datamodel in the database.

What shall I do?



5 Replies

MA Mohanram Anbukkarasu Syncfusion Team May 13, 2021 10:31 AM UTC

Hi Nikos,  
   
Thanks for contacting Syncfusion support.   
   
We are able to understand the reported scenario. But unfortunately, it is not possible to achieve your requirement without implementing INotityPropertyChanged interface to the underlying data model. Please let us know if you require any other assistance from us.   
   
Regards,  
Mohanram A.  



NI Nikos May 13, 2021 11:44 AM UTC

Dear Mohanram,

ok. I understood.

I found a bypass. I explicitly call .View.Refresh() when I want to refresh sFDataGrid.
Will this work or shall I expect negative side effects?


MA Mohanram Anbukkarasu Syncfusion Team May 14, 2021 05:44 AM UTC

Hi Nikos, 

Thanks for the update.  

You can use SfDataGrid.View.Refresh method. But it will affect the expand state of the details view in the SfDataGrid. It will collapse the expanded details view. If you are not using details view in your application you can use View.Refresh method. Please let us know if you require any other assistance from us.  

Regards, 
Mohanram A. 



NI Nikos May 14, 2021 05:48 AM UTC

No, I do not need anything else.

Thank you very much.


MA Mohanram Anbukkarasu Syncfusion Team May 14, 2021 05:52 AM UTC

Hi Nikos, 

Thanks for the update.  

Regards, 
Mohanram A. 


Loader.
Up arrow icon