I noticed after debugging a problem when editing some rather complex rows in a grid that the grid internally calls Telerik.Blazor.Extensions.ObjectExtensions.Clone(...) to create a deep clone for editing. If the object being cloned implements System.ICloneable then this is ignored and an attempt is made to clone it using reflection - the problem is that ObjectExtensions.Clone(...) fails for a number of cases and observing ICloneable would give a developer the means to implement the correct cloning behaviour.
I'm not asking for ObjectExtensions.Clone(...) to be fixed in any way (after all, no matter what you do there will always be some cases it cannot handle), just to use ICloneable where possible.
As an aside, the failed cases were:
Hi Simon,
Adding support for the ICloneable interface might be a nice thing to do.
I am not sure if it will provide full flexibility, though, as sometimes there may be no model for the grid to clone - e.g., if it has no data or it is bound to a dynamic object (such as expando) so that it does not even have the type. In such cases, inserting items may still be needed, or the user may try to filter.
So, for that we were thinking of exposing an event the grid will fire when it needs an instance of the row model. You can Vote for that and Follow its implementation here: https://feedback.telerik.com/blazor/1511466-onneedmodel-event-to-fire-before-onedit-before-item-insertion-and-before-filtering-where-i-can-provide-my-own-model-instance.
When the actual technical investigation happens, we will keep both ideas in mind and we will review them again. Perhaps both will have merit, or perhaps we will choose only the event, I can't say at this point.
It is important to note that it is likely that those scenarios won't work in general. The grid fields need to be bound to primitive or value types, collections and arrays and other objects are not supported exactly because there are no operations defined for them in the framework - it cannot compare two arrays to provide sorting or filtering. You can read more about this here: https://docs.telerik.com/blazor-ui/components/grid/columns/bound#notes.
Regards,
Marin Bratanov
Progress Telerik
Тhe web is about to get a bit better!
The Progress Hack-For-Good Challenge has started. Learn how to enter and make the web a worthier place: https://progress-worthyweb.devpost.com.