Question

I have a GridControl which is binded by List using Entity. I am applying Grouping to Grid at runtime. I want to Remove/change grouping column at runtime from code behind is it possible in 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;

            }
        }

Now Clicking on Button i want to remove or change the grouping in WPF from code behind?

Was it helpful?

Solution

To ungroup data by the values of a single column, do one of the following:

To ungroup the grid, use the GridControl.ClearGrouping method.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top