Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
1240
Expanders Stop Working
posted

I ran into a problem with expanders not showing the contents of a child collection.  I found that when a child collection is cleared out the grid re-evaluates which FieldLayout to use.  Since the contents of the child collection is now empty it has no data type to check against.  I think it then uses the type of collection to check for the FieldLayout to use.  The problem happens when the collection’s type is a base type, but the contents end up being a collection of types derived from the base type.  This causes the grid to not find a FieldLayout to use and creates an empty one.  From there on out, the expanders no longer work.  I’ve created a test app which shows this condition and attached it.  I’ve gotten around this issue by hooking into the AssigningFieldLayoutToItem handler and forcing the FieldLayout.  Is there a better solution that this?

Thanks

Dan

Grid Expander Test.zip
Parents
No Data
Reply
  • 138253
    Offline posted

    Hello again Dan,

    You can also set the Key of the FieldLayout to the type of your base class like this:

    <igDP:FieldLayout Key="{x:Type local:BaseClass}" xmlns:local="clr-namespace:GridTest">
        <igDP:FieldLayout.Fields>
            <igDP:Field Label="" Name="SubCollection" />
            <igDP:Field Label="Property1" Name="Property1" />
            <igDP:Field Label="Property2" Name="Property2" />
            <igDP:Field Label="Property3" Name="Property3" />
        </igDP:FieldLayout.Fields>
    </igDP:FieldLayout>

     

    Hope this helps you.

     

Children
No Data