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
65
How are the IsExpandable and AutoGenerateFields properties supposed to work?
posted

I'm writing a small test app to try and figure this out and so far I have this :

 

  <igDP:XamDataGrid
    x:Name="xamDataGrid"
    DataSource="{Binding}"
      Theme="Office2k7Blue"
    >

        <igDP:XamDataGrid.FieldLayoutSettings>
            <igDP:FieldLayoutSettings
                AutoGenerateFields="False"
                ExpansionIndicatorDisplayMode="CheckOnDisplay"
                HighlightAlternateRecords="True">
            </igDP:FieldLayoutSettings>
        </igDP:XamDataGrid.FieldLayoutSettings>

        <igDP:XamDataGrid.FieldLayouts>
      <igDP:FieldLayout Key="master">
        <igDP:FieldLayout.Fields>
            <igDP:Field Name="SubLocations" IsExpandable="True"/>
            <igDP:Field Name="ID" Visibility="Collapsed" />
            <igDP:Field Name="Name" />
            <igDP:Field Name="Description">
          </igDP:Field>
        </igDP:FieldLayout.Fields>
      </igDP:FieldLayout>

      <igDP:FieldLayout Key="detail">
        <igDP:FieldLayout.Fields>
            <igDP:Field Name="ID" />
            <igDP:Field Name="Name" />
            <igDP:Field Name="Description" Width="20" />
        </igDP:FieldLayout.Fields>
      </igDP:FieldLayout>
    </igDP:XamDataGrid.FieldLayouts>

  </igDP:XamDataGrid>

Which is bound to some data using this class hierarchy :

    public class LocationParent : Location
    {
        public int NumChildren { get { return SubLocations != null? SubLocations.Length : 0; }}
        public Location[] SubLocations { get; set; }
    }

    public class Location
    {
        public int ID { get; set; }
        public string Name { get; set; }
        public string Description { get; set; }       
    }

Everywhere I've read so far suggests that adding IsExpandable="True" to a field will indicate to the data grid that that field's children should have a field layout applied to them, but this doesn't happen and all I end up with is "Location[] Array" displayed when I expand the item.

This may be a misunderstanding on my part, but what I also don't understand is why, when I have AutogenerateFields="False", the records are not expandable at all.

I'd like to be able to show child records which have a field layout showing only some of their actual properties, but unless AutoGenerateFields is set to true, I can't seem to ever show them, and when that's the case, the datagrid auto generates all the fields I don't want to see!