如何在代码隐藏的WPF中删除WPF中DevExpress GridControl运行时的分组?

时间:2013-05-24 06:12:09

标签: c# wpf devexpress gridcontrol

我有一个GridControl,它由List使用Entity绑定。我正在运行时将Grouping应用于Grid。我想在运行时从代码中删除/更改分组列是否可以在wpf?

<dxg:GridControl Name="grdInfill"  Height="700" VerticalAlignment="Top" >
        <dxg:GridControl.Columns>
            <dxg:GridColumn FieldName="GlassType" AllowEditing="False"   />
            <dxg:GridColumn FieldName="GlassDescription" GroupValueTemplate="{StaticResource descriptionHeader}">
                <!--GroupValueTemplate="{StaticResource descriptionHeader}"-->
                <!--Header="GlassDescription" DisplayMemberBinding="{Binding Path=RowData.Row.GlassDescription, Mode=TwoWay}"-->
            </dxg:GridColumn>
            <dxg:GridColumn FieldName="GlassType" AllowEditing="False" />
            <dxg:GridColumn Name="qty" Header="Quantity" AllowEditing="False" DisplayMemberBinding="{Binding Path=RowData.Row.Quantity, Mode=TwoWay}" /> <!--FieldName="Quantity"-->
            <dxg:GridColumn FieldName="Width" AllowEditing="False" Header="Length"/>
            <dxg:GridColumn FieldName="Height" AllowEditing="False"/>
            <dxg:GridColumn FieldName="Elevation" AllowEditing="False"/>
            <dxg:GridColumn FieldName="Mark" AllowEditing="False"/>
            <dxg:GridColumn FieldName="GlassTag" AllowEditing="False"/>
            <dxg:GridColumn FieldName="WallLocation" AllowEditing="False"/>
            <dxg:GridColumn FieldName="SquareFoot" AllowEditing="False"/>
            <dxg:GridColumn FieldName="Weight" AllowEditing="False"/>
            <dxg:GridColumn FieldName="UnitCost" AllowEditing="False"/>
            <dxg:GridColumn FieldName="TotalCost" AllowEditing="False"/>
            <dxg:GridColumn FieldName="FuelSurcharge" AllowEditing="False"/>

        </dxg:GridControl.Columns>
        <dxg:GridControl.View>
            <dxg:TableView ShowTotalSummary="True" AutoWidth="True" DetailHeaderContent="True"  ShowIndicator="False" ShowGroupPanel="False"><!--GroupRowTemplate="{StaticResource descriptionHeader}"-->
            </dxg:TableView>
        </dxg:GridControl.View>
    </dxg:GridControl>

protected void GetAllInfills()
        {
            List<Infill> infillList = new List<Infill>();
            infillList=BLL.GetAllInfills();
            if (infillList != null)
            {
                grdInfill.ItemsSource = infillList;

                grdInfill.GroupBy(grdInfill.Columns["GlassType"], ColumnSortOrder.Ascending);
                grdInfill.GroupBy(grdInfill.Columns["GlassDescription"], ColumnSortOrder.Ascending);

                grdInfill.AutoExpandAllGroups = true;

            }
        }

现在点击按钮我想从后面的代码中删除或更改WPF中的分组?

1 个答案:

答案 0 :(得分:3)

要按单列的值取消组合数据,请执行以下操作之一:

要取消组合网格,请使用GridControl.ClearGrouping方法。