Ungrouping Grid Programatically

I am attempting to ungroup a grid that is initialized as being grouped.  I have tried the following methods:

#1

Grid.GroupSettings = new GridGroupSettings();
Grid.Refresh();

#2

Grid.GroupSettings.Columns = null;
Grid.Refresh();

#3

await Grid.ClearGrouping();
None of the above methods result in the grid being ungrouped.

1 Reply 1 reply marked as answer

VN Vignesh Natarajan Syncfusion Team June 3, 2020 05:36 AM UTC

Hi Ernest,  
 
Thanks for contacting Syncfusion support.  
 
Query: “I am attempting to ungroup a grid that is initialized as being grouped.  I have tried the following methods: 
 
From your query we understand that you want to remove grouping from Grid. We suggest you to achieve your requirement using ClearGrouping (to ungroup all columns) method or UnGroupColumn (to ungroup particular column ) method of Grid.  Refer the below code example.  
 
<SfButton Content="UnGroup" OnClick="UnGroup"></SfButton> 
  
<SfButton Content="UnGroup CustomerID" OnClick="UnGroupCus"></SfButton> 
  
<SfGrid @ref="Grid" DataSource="@Orders" AllowGrouping="true" Height="400"> 
    <GridGroupSettings Columns="@Initial"></GridGroupSettings> 
    <GridColumns> 
. . . . . . . 
    </GridColumns> 
</SfGrid> 
@code{ 
    SfGrid<Order> Grid { getset; } 
    public List<Order> Orders { getset; } 
    public async Task UnGroup() 
    { 
        await Grid.ClearGrouping(); 
    } 
    public async Task UnGroupCus() 
    { 
        await Grid.UngroupColumn("CustomerID"); // pass field value as argument to ungroup particular column 
    } 
} 
 
For your convenience we have prepared a sample which can be downloaded from below 
 
 
Refer our API documentation for your reference. 
 
 
Kindly get back to us if you have further queries.   
 
Regards, 
Vignesh Natarajan 


Marked as answer
Loader.
Up arrow icon