Unplanned
Last Updated: 05 Feb 2024 12:29 by Constantinos Petridis
Ron Hary
Created on: 02 May 2023 13:10
Category: Grid
Type: Feature Request
2
Support for IDictionary and value mapper or/and custom implementations of IDictionary
Support for IDictionary and value mapper or/and custom implementations of IDictionary
1 comment
Constantinos Petridis
Posted on: 05 Feb 2024 12:29

Currently TelerikGrid works in two modes

a "Model" mode where each row is mapped to a class object and each field is mapped to a property

a "Dynamic" mode where each row can be a Dictionary<string, object> or an ExpandoObjec

Selection of this mode is done in code using an internal bool IsDynamicObject readonly property that makes the following check

internal bool IsDynamicObject => typeof(TItem) == typeof(Dictionary<string, object>) || typeof(TItem) == typeof(ExpandoObject);

I also agree with Ron, and I would like more freedom on the usage of Dynamic objects in TelerikGrid.

In out implementation, we use a custom object that inherits from Dictionary<string, object>, in order to add more functionality (something like a DataTable) and events. The IsDynamicObject, fails when the TItem is not a Dictionary<string,object> but it would not fail if the check was against IDictionary<string, object>.

In order for our code to work, we have to define the TelerikGrid's TItem to Dictionary<string, object> but pass as data a collection of our object that inherits from Dictionary<string, object>. Adding or editing rows is also tricky because of the above workarround. It would be much easier to support custome Dictionary implementations that will allow us to have a better and more dynamic object model.