We use Infragistics controls which have this feature called "Bands", it's basically a child grid, quite cool stuff.
The issue we're having is when binding to a DeepLoaded list of entity objects, the UltraGrid can't seem to discover the Bindable Properties for the objects in the sub collection. We have an Order entity with an OrderLineCollection property of type TList<OrderLine>, basic stuff...
The UltraGrid can see the number of objects in the OrderLineCollection property, it displays the correct amount of lines, but there is no data displayed, no columns show up.
I investigated this a bit, and it seems that UltraGrid passes into ListBase.GetItemProperties() a type of TList<OrderLine> instead of OrderLine. ListBase.GetItemProperties() delegates to EntityHelper.GetBindableProperties() which returns an empty PropertyDescriptorCollection for this type, thus no columns are displayed. I changed EntityHelper.GetBindableProperties() to detect if the Type that is being reflected is a generic type, and if so use the first generic argument to this type instead. I saw this somewhere else in the code, I believe in the DeepLoad a similar check/assumption is made.
This works like a charm for me, the question I have: Is this correct?
public static PropertyDescriptorCollection GetBindableProperties(Type type)
{
// create a filter so we only return the properties that have been designated as bindable
Attribute[] attrs = new Attribute[] { new BindableAttribute() };
// save the bindable properties in a local field
if (type.IsGenericType)
type = type.GetGenericArguments()[0];
return TypeDescriptor.GetProperties(type, attrs);
}
I'm making an assumption that when requesting the bindable properties for a generic type, it's got to be a TList. This doesn't sound quite right to me though, if you guys can validate this for me, I would really appreciate it. I have hardly any experience with the innards of the binding mechanisms. Obviously the check can be made more specific to make sure it's a TList or a BindingList.
I'm just not sure if this is the correct way to approach this, I appreciate any help.
"Small is the number of them that see with their own eyes, and feel with their own hearts" Albert Einstein