Articles in this section
Category / Section

How to maintain the DetailsView expanded state when Sorting and Grouping the DataGrid (SfDataGrid)?

2 mins read

When you are processing the data operation (Grouping, Sorting) the expanded DetailsViewDataGrid is collapsed in WPF DataGrid (SfDataGrid).

Grouping

You can expand all the DetailsViewDataGrid when processing the grouping in SfDataGrid.GroupColumnDescriptions.CollectionChanged event.

this.dataGrid.GroupColumnDescriptions.CollectionChanged += GroupColumnDescriptions_CollectionChanged;
 
private void GroupColumnDescriptions_CollectionChanged(object sender, System.Collections.Specialized.NotifyCollectionChangedEventArgs e)
{
    dataGrid.Dispatcher.BeginInvoke(System.Windows.Threading.DispatcherPriority.ApplicationIdle,
         new Action(() =>
         {
             this.dataGrid.ExpandAllDetailsView();
         }));
}

 

Sorting

You can expand all the DetailsViewDataGrid when processing sorting in SfDataGrid.SortColumnsChanged event.

this.dataGrid.SortColumnsChanged += DataGrid_SortColumnsChanged;
 
private void DataGrid_SortColumnsChanged(object sender, GridSortColumnsChangedEventArgs e)
{
    dataGrid.Dispatcher.BeginInvoke(System.Windows.Threading.DispatcherPriority.ApplicationIdle,
         new Action(() =>
         {
             this.dataGrid.ExpandAllDetailsView();
         }));
}

 

Expand All

View sample in GitHub

 

Did you find this information helpful?
Yes
No
Help us improve this page
Please provide feedback or comments
Comments (0)
Please sign in to leave a comment
Access denied
Access denied