Paste problems when grid binded to dynamic objects

Hi all,

We are studying the SfDatagrid to see if we go ahead with enterprised license but we are facing a main issue when binding the grid item source with dynamic objects (ObservableCollection<dynamic>).

The problem appears when trying to paste a value from one cell to another one.

The data source (ObservableCollection<dynamic>) is updated as I could watch in the code behind but the grid does not show the updated element until I sort it.

Also, if I paste from one cell to another, the old value remains visible in the grid (but updated in the source collection) but if I enter in the edit mode (double click in the cell where I have pasted) I see the new value.

I would say it is a refresh problem that only appears when working with dynamics.

I have attached a sample project where you can clone the repo and check the difference between one grid with dynamic collection (problems as commented), and another with a custom model (it works).


Regards,


Attachment: SfDynamicGridPoC__34821891.zip

1 Reply 1 reply marked as answer

GS Gokul S Subramani Syncfusion Team August 8, 2024 01:52 PM UTC

Hi Alvaro,


Based on the information provided, when using the DynamicObject-bound grid, the DataGrid did not update automatically when values were changed. This happened because DynamicObject allows you to define properties at runtime but does not inherently support change notification. When you modify a property, DynamicObject does not inform the UI about these changes. As a result, the value was changed in the underlying collection, but it did not reflect in the view.


We have now implemented INotifyPropertyChanged in your custom DynamicDictionary class. This allows the object to notify the DataGrid when a property value changes. Therefore, when we change or update a value, the DataGrid immediately reflects these changes in the UI.


We have resolved the reported issue and modified your workaround based on your requirements. Please review the updated solution below. If you need further assistance, feel free to let us know. We are happy to help.


Thank you for your understanding and cooperation.


Best Regards,

Gokul S


Attachment: SfDynamicGridPoC__ccd7ed50.zip

Marked as answer
Loader.
Up arrow icon