ObservableCollection

Hello,

I was looking at this sample: https://www.syncfusion.com/faq/blazor/data-binding/how-do-you-show-real-time-data-updates-using-observablecollection

I have 2 questions:

  1. When running this, when I click on the Update Data button, I noticed that PropertyChanged is always null. Why is that?

        private void NotifyPropertyChanged(String propertyName)
        {
            if (PropertyChanged != null) //this is always null
            {

//this is never called
PropertyChanged(this, new PropertyChangedEventArgs(propertyName)); } }

2. If I remove the INotifyPropertyChanged interface from the OrdersDetailsObserveData class, the grid still updates the customer ID. I thought that INotifyPropertyChanged had to be implemented for this to work. What am I missing?

Thank you for your assistance.


3 Replies

RN Rahul Narayanasamy Syncfusion Team March 7, 2022 03:40 PM UTC

Hi Rav, 
 
Greetings from Syncfusion. 
 
We are currently checking the reported query from our end and we will update the further details within two business days. Until then we appreciate your patience. 
 
Regards, 
Rahul 



RA Rav April 16, 2022 12:39 PM UTC

Hello,


It's been over a month.  Can I get a response to this please?


Thank you



RN Rahul Narayanasamy Syncfusion Team April 21, 2022 12:34 PM UTC

Hi Rav,


Sorry for the inconvenience and sorry for the delay in getting back to you.


While binding Oberservable collection data, the PropertyChanged event value will get only if we have added the handler to that Observable collection CollectionChanged event. If we have not added that CollectionChanged event handler, then it won’t get the PropertyChanged value.


https://stackoverflow.com/questions/52935571/propertychanged-event-is-null-after-changing-values-inside-property


Also, for binding the Observable data to the normal HTML table, then it is not needed to implement the INotifyPropertyChanged interface. Suppose if we bind any normal list data to an HTML table. If we change/ update any data, then it will change automatically.


For the Grid component, we have added the CollectionChanged event handler in our source. So while updating the value while using Blazor Grid, you can get the PropertyChanged value. Find the below documentation for your reference.


https://blazor.syncfusion.com/documentation/datagrid/data-binding#observable-collection


Please let us know if you have any concerns.


Regards,

Rahul


Loader.
Up arrow icon