Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
555
reset row grouping
posted

How can I reset row grouping programmatically ?   The following statement does nothing:

if (ultraGrid1.Rows.IsGroupByRows) ultraGrid1.DisplayLayout.ResetGroupByBox();

In my grid I have grouped the rows by draging one column header over my group area initialized with

ultraGrid1.DisplayLayout.ViewStyleBand = ViewStyleBand.OutlookGroupBy;

ultraGrid1.DisplayLayout.Override.AllowGroupBy = DefaultableBoolean.True;

 

Thank for a hint

Kagel

 

Parents
  • 45049
    posted

    What do you mean by "reset row grouping"?

    If you mean that you want to programmatically ungroup any columns that were grouped, you can loop through all columns in all bands of your grid, and set the IsGroupByColumn property to false.

    If you want to do this more efficiently, you can instead go through the SortedColumns collection on each band, and set IsGroupByColumn to false on each of these columns.  You can do this because grouping by a column implicitly sorts it.  If you do this, you should loop through the collection "backwards," since removing the grouping will modify the collection.  Below is the approach I'd use (note that I haven't tested this so it may need further modification)

    using Infragistics.Win.UltraWinGrid;
    ...
    foreach (UltraGridBand band in grid.DisplayLayout.Bands)
    {
        for (int i = band.SortedColumns.Count - 1; i >= 0; i--)
        {
            UltraGridColumn col = band.SortedColumns[i];
            col.IsGroupByColumn = false;
        }
    }

Reply Children