问题
First here is my structure
layer 1 >Collection of
<Objects>
layer 2-->Each
Object
has another collection ofObjects
inside of it
Desired result:
- The first collection is show in the datagrid with an expander next to it
- Under the expander for each row there is the second collection of objects that relate to the selected layer 1
I am successfully collapsing the unwanted fields on layer 1.
However, when you click the expander icon to view layer two on the selected object from layer 1 you see all of the fields that are dynamically generated from the object.
Question: How do you hide the fields of layer 2
<igWPF:XamDataGrid Theme="IGTheme" DataSource="{Binding layer1Collection}">
<igWPF:XamDataGrid.FieldLayouts>
<igWPF:FieldLayout>
<igWPF:FieldLayout.Fields>
<igWPF:Field Name="val1" Visibility="Collapsed"/>
<igWPF:Field Name="val2" Visibility="Collapsed"/>
<igWPF:Field Name="val3" Visibility="Collapsed"/>
<igWPF:Field Name="val4" Visibility="Collapsed"/>
<igWPF:Field Name="val5" Visibility="Collapsed"/>
<igWPF:Field Name="val6" Visibility="Collapsed"/>
<igWPF:Field Name="val7" Visibility="Collapsed"/>
<igWPF:Field Name="val8" Visibility="Visible"/>
<igWPF:Field Name="val9" Visibility="Visible"/>
<!-- This is where the second layer is-->
<igWPF:Field Name="val10" Visibility="Visible" IsExpandable="True" Label="Details" IsSelected="True" IsPrimary="True" />
</igWPF:FieldLayout.Fields>
</igWPF:FieldLayout>
</igWPF:XamDataGrid.FieldLayouts>
</igWPF:XamDataGrid>
回答1:
In order to mask the child grid you must create a second field layout and tie them together like this...
<igWPF:XamDataGrid.FieldLayouts>
<igWPF:FieldLayout Key="layer1">
<igWPF:FieldLayout.Fields>
<igWPF:Field Name="val1" Visibility="Collapsed"/>
<igWPF:Field Name="val2" Visibility="Collapsed"/>
<igWPF:Field Name="val3" Visibility="Collapsed"/>
<igWPF:Field Name="val4" Visibility="Collapsed"/>
<igWPF:Field Name="val5" Visibility="Collapsed"/>
<igWPF:Field Name="val6" Visibility="Collapsed"/>
<igWPF:Field Name="val7" Visibility="Collapsed"/>
<igWPF:Field Name="val8" Visibility="Visible"/>
<igWPF:Field Name="val9" Visibility="Visible"/>
<!-- This is where the second layer is-->
<igWPF:Field Name="details" Visibility="Visible" IsExpandable="True" Label="Details" IsSelected="True" IsPrimary="True" />
</igWPF:FieldLayout.Fields>
</igWPF:FieldLayout>
<igWPF:FieldLayout Key="Detail" ParentFieldName="details" ParentFieldLayoutKey="layer1">
<igWPF:FieldLayout.Fields>
<igWPF:Field Name="L2val1" Label="L2val"/>
<igWPF:Field Name="L2val2" Label="L2val"/>
<igWPF:Field Name="L2val3" Label="L2val"/>
<igWPF:Field Name="L2val4" Label="L2val"/>
<igWPF:Field Name="L2val" Visibility="Collapsed"/>
</igWPF:FieldLayout.Fields>
</igWPF:FieldLayout>
</igWPF:XamDataGrid.FieldLayouts>
来源:https://stackoverflow.com/questions/24658553/masking-child-table-of-xamdatagrid-hierarchical-grid