Hi!
I have a SfDataGrid and I made a DetailsViewDefinition for that. I also make ExpandAllDetailsView from code to expand all details and I want to keep these open, but right after the first reorder or first regroup these will collapse.
I tried kinda every events (what made sense) to reopen, but only the MouseUp was the closest to the goal, but that was kinda bad because it does not work on header and will reopen on every mouseups, so it was a very bad hack.
I would like to know a good and working way to keep the rowdetail open even after events like reorder/group.
Thanks!
|
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();
}));
}
|
|
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();
}));
} |
Hi Ponyist,Thank you for using Syncfusion controls.
You can achieve your requirement by using SfDataGrid.ExpandAllDetailsView method. For grouping, you can achieve this by 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();}));}
For sorting you can achieve this by 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();}));}
Sample link: https://www.syncfusion.com/downloads/support/directtrac/general/ze/DetailsViewGrid_KeepExpand600241785Please check the sample and let us know if you need further assistance on this.
Regards,Susmitha S