Masking child table of XamDataGrid Hierarchical Grid

别说谁变了你拦得住时间么 提交于 2019-12-12 01:42:59

问题


First here is my structure

  • layer 1 >Collection of <Objects>

  • layer 2-->Each Object has another collection of Objects 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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!