Skip to content

SyncfusionExamples/How-to-collapse-the-details-view-datagrid-inside-the-Groups-in-DataGrid-SfDataGrid-

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

12 Commits
 
 
 
 
 
 

Repository files navigation

How to collapse the details view datagrid inside the Groups in DataGrid

About the sample

By default, DetailsViewDataGrid expanded state is maintain when group of WinForms DataGrid (SfDataGrid) is collapsed. If we need to collapse the DetailsViewDataGrid when group of DataGrid is collapsed, this can be achieved by disabling the IsExpanded of DetailsViewDataGrid in SfDataGrid.GroupExpanding event.

this.sfDataGrid1.GroupExpanding += SfDataGrid1_GroupExpanding;

private void SfDataGrid1_GroupExpanding(object sender, Syncfusion.WinForms.DataGrid.Events.GroupChangingEventArgs e)
{
    CollapseAllNestedGrids(e.Group);
}

void CollapseAllNestedGrids(Group group)
{
    if (group != null && group.Records != null)
    {
        foreach (var item in group.Records)
        {
            if (item.IsGroups == false)
                item.IsExpanded = false;
        }
    }
    if (group.Groups != null)
    {
        foreach (var item in group.Groups)
            CollapseAllNestedGrids(item);
    }
}

Requirements to run the demo

Visual Studio 2015 and above versions

About

How to collapse the details view datagrid inside the Groups in DataGrid (SfDataGrid)?

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 5

Languages