CodeSmith Community
Your Code. Your Way. Faster!

issue with ListBase.GetItemProperties() and EntityHelper.GetBindableProperties()

Latest post 10-27-2006 9:15 AM by GRAW. 3 replies.
  • 10-23-2006 1:50 PM

    • GRAW
    • Top 25 Contributor
    • Joined on 06-23-2006
    • Posts 157
    • Points 4,560

    issue with ListBase.GetItemProperties() and EntityHelper.GetBindableProperties()

    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
    • Post Points: 35
  • 10-26-2006 10:02 AM In reply to

    • GRAW
    • Top 25 Contributor
    • Joined on 06-23-2006
    • Posts 157
    • Points 4,560

    Re: issue with ListBase.GetItemProperties() and EntityHelper.GetBindableProperties()

    Can anyone help me out with this?
    "Small is the number of them that see with their own eyes, and feel with their own hearts" Albert Einstein
    • Post Points: 5
  • 10-26-2006 11:26 AM In reply to

    Re: issue with ListBase.GetItemProperties() and EntityHelper.GetBindableProperties()

    Hrmmm, it should be passing the type of the entity anyway nad not the list.  But yes, I can see that as being a good safeguard.  We will add it.

    Robert Hinojosa
    -------------------------------------
    Member of the Codesmith Tools, .netTiers, teams
    http://www.nettiers.com
    -------------------------------------
    • Post Points: 35
  • 10-27-2006 9:15 AM In reply to

    • GRAW
    • Top 25 Contributor
    • Joined on 06-23-2006
    • Posts 157
    • Points 4,560

    Re: issue with ListBase.GetItemProperties() and EntityHelper.GetBindableProperties()

    Yeah, it's really strange.

    And what threw me off is the fact that when we set the BindingSource's DataSource to just an Order entity object it was working correctly, it is only when setting the DataSource to a TList<Order> that it was having the issues with requesting the bindable properties for TList<OrderLine> instead of just OrderLine.

    "Small is the number of them that see with their own eyes, and feel with their own hearts" Albert Einstein
    • Post Points: 5
Page 1 of 1 (4 items) | RSS
Copyright © 2008 CodeSmith Tools, LLC
Powered by Community Server (Commercial Edition), by Telligent Systems