How to merge cell on my parent SfDatagrid if I've DetailsViewDefinition

Hello,

I would like to use the QueryCoveredRange feature while having a syncfusion:SfDataGrid.DetailsViewDefinition.

My goal is to merge only columns, not rows, so that I can continue using syncfusion:SfDataGrid.DetailsViewDefinition.


Thank you in advance for your help.

Best regards,


1 Reply 1 reply marked as answer

EE Elavazhagan Elangovan Syncfusion Team July 18, 2025 12:05 PM UTC

Hi Corentin Wadin,

We have reviewed your query. Your requirement is to merge cells column-wise in the DataGrid when the records contain a DetailsViewDataGrid. Unfortunately, this scenario is not supported. The DataGrid control does not allow cell merging when the records include a DetailsViewDataGrid or when the HideEmptyGridViewDefinition property is set to false. This limitation is mentioned in the user guide.

UG Link:
MergeCellsLimitations

The HideEmptyGridViewDefinition property determines whether the expander should be hidden when the relational column property contains an empty collection or is null.

UG Link:
HideEmptyGridViewDefinition

However, column-wise cell merging is supported when the records do not contain a DetailsViewDataGrid , and this can be achieved using the QueryCoveredRange event.


Code snippet used to merge cells while record does not have DetailsViewDataGrid:


dataGrid.QueryCoveredRange += OnQueryCoveredRange;

 private void OnQueryCoveredRange(object sender, GridQueryCoveredRangeEventArgs e)

 {

    //Here customize based on your scenario
    //merge cells column-wise for records that do not contain a DetailsViewDataGrid

     if (e.RowColumnIndex.RowIndex == 1)

     {

         if (e.RowColumnIndex.ColumnIndex >= 1 && e.RowColumnIndex.ColumnIndex <= 3)

         {

             e.Range = new CoveredCellInfo(1, 3, 1, 1);

             e.Handled = true;

         }

     }         

     if (e.RowColumnIndex.RowIndex == 7)

     {

         if (e.RowColumnIndex.ColumnIndex >= 2 && e.RowColumnIndex.ColumnIndex <= 3)

         {

             e.Range = new CoveredCellInfo(2, 3, 7, 7);

             e.Handled = true;

         }

     }

     if (e.RowColumnIndex.RowIndex == 9)

     {

         if (e.RowColumnIndex.ColumnIndex >= 1 && e.RowColumnIndex.ColumnIndex <= 2)

         {

             e.Range = new CoveredCellInfo(1, 2, 9, 9);

             e.Handled = true;

         }

     }

 }


UG Link:MergeCellsInMasterDetailsView

Find the sample demo in the attachment.

Please let me know if you have any concerns.

Regards,

Elavazhagan E

If this post is helpful, please consider Accepting it as the solution so that other members can locate it more quickly


Attachment: DataGridDemo_62342724.zip

Marked as answer
Loader.
Up arrow icon