Nested dynamic objects
New DiscussionApologies in advance, the work VM I do the coding on doesn’t have internet access nor let me copy-paste code out of it, so it’s gotta be all descriptions.
I’m trying to use UltraGrid to display the contents of a list of nested ExpandoObjects. The list (ExpandoList) is derived from BindingList<object> that implements ITypedList; the GetItemProperties() method checks if the first item is an ExpandoObject, in which case it builds a list of PropertyDescriptors constructed from the contents of that first item.
This all works great. But when I test with one property that is another ExpandoList of dynamic objects, the grid creates a new child band for it, but reuses the properties from the parent ExpandoObject to build the child band’s columns, not the child’s properties. I’ve stepped through it, it’s definitely requesting and getting the property descriptors for the child. And if I break in the InitializeLayout event, it actually shows two child bands: one with the parent properties (wrong) which is being used, and one with the child properties (right) which is not.
If I test the same data with strongly typed classes instead, it loads the child band columns correctly. So the only thing I can think of is that since both parent and child are technically the same type (ExpandoObject), the grid is caching the properties it got for that type from the parent and reusing it for the child. But then why is it bothering to request the child properties at all?
Is there any way to make this work? Or is there a better way to get the grid to display nested, unknown-at-design-time data?