Master-Detail datagrid ResetAutoCalculation on detailview

Hi,

I am trying to reset the calculated column width of a detailsview sfdatagrid at runtime.

For the parent datagrid I do this:

                        MainDataGrid.GridColumnSizer.ResetAutoCalculation(MainDataGrid.Columns[0]);

                        MainDataGrid.GridColumnSizer.ResetAutoCalculation(MainDataGrid.Columns[1]);

                        MainDataGrid.GridColumnSizer.Refresh();


This works fine - however, I am unable to find out to do the same for the child sfdatagrid of the selected item (on the main sfdatagrid).

Is there a way to achieve this and if yes, how?

Kind regards,

Niels van Strien

>





1 Reply

DM Dhanasekar Mohanraj Syncfusion Team April 6, 2022 03:12 PM UTC

Hi NM van Strien,

You can achieve your requirement by using the below code,

var detailView = this.dataGrid.GetDetailsViewGrid(this.dataGrid.SelectedIndex, "OrderDetails");

detailView.GridColumnSizer.ResetAutoCalculation(detailView.Columns[3]);

detailView.GridColumnSizer.Refresh();

We have created the sample based on your requirement. Please check the sample and revert us if you need further assistance.

Regards,
Dhanasekar M.


Attachment: DetailsView_WPF_3dbbba3f.zip

Loader.
Up arrow icon