掩蔽XamDataGrid层次网格的子表

时间:2014-07-09 16:01:57

标签: wpf xaml infragistics

首先是我的结构

  • 第1层&gt; <Objects>

  • 的集合
  • 第2层 - &gt;每个Object内部都有Objects的另一个集合

期望的结果:

  • 第一个集合显示在datagrid中,旁边有一个扩展器
  • 在每行的展开器下,有第二个与所选图层1
  • 相关的对象集合

我成功折叠了第1层上不需要的字段。

但是,当您单击展开器图标以从第1层查看所选对象上的第二层时,您会看到从该对象动态生成的所有字段。

问题:如何隐藏第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 个答案:

答案 0 :(得分:2)

为了掩盖子网格,你必须创建第二个字段布局并将它们绑在一起......就像这样......

<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>